SQL 명령어 구문들 (Statements)

use test
CREATE TABLE userinfo (
number  int,
name  char(10),
id  char(8),
password char(10),
age  int,
birthday  char(10),
sex  char(1),
daytype  char(1),
zip  char(7),
address  varchar(50),
phone  char(15),
company varchar(50),
comaddr varchar(100),
comphone char(15),
handphone char(15),
pager  char(15),
fax  char(15),
email  varchar(40),
compos  varchar(20),
partcode char(10),
introduce text
)
SELECT * FROM userinfo
SELECT id, name, address, phone FROM userinfo
SELECT * FROM userinf WHERE age >= 25
SELECT DISTINCT name FROM userinfo
SELECT name AS fullname FROM userinfo
SELECT * FROM userinfo WHERE name LIKE '김%' OR (sex = 'm' AND age >= 25)
SELECT * FROM userinfo ORDER BY name DESC
SELECT top 10 * FROM userinfo ORDER BY age DESC
SELECT avg(age) as ageAvg FROM userinfo GROUP BY partcode
SELECT AVG(age) AS ageAvg FROM userinfo GROUP BY partcode HAVING ageAvg >= 33
CREATE TABLE userlog (
id char(8),
login int,
userip char(15)
)
INSERT INTO userlog VALUES('tiger', 30, '203.220.22.10')
INSERT INTO userlog(id, login) VALUES('star', 20)
SELECT * FROM userlog
DELETE userlog WHERE login < 30
begin tran
UPDATE userlog SET login = 25, userip = '203.220.22.20' WHERE id = 'tiger'
rollback tran

by 케찹만땅 | 2010/03/12 11:10 | ICT 정보와 IoT | 트랙백

트랙백 주소 : http://wpkc.egloos.com/tb/4696191
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
※ 로그인 사용자만 덧글을 남길 수 있습니다.

◀ 이전 페이지          다음 페이지 ▶