DB(SQL)

테이터 입력, 수정, 삭제

_주야 2012. 7. 27. 11:21

#. insert(데이터 입력)

SQL> insert into gaip(id,pass,name,age)
  2  values('junho1','1234','이준호',18);

1 개의 행이 만들어졌습니다.

SQL> insert into gaip(id,pass,name,age)
  2  values('hana','1111','이하나',17);

1 개의 행이 만들어졌습니다.

SQL> insert into gaip(id,pass,name,age)
  2  values('hong','aaaa','홍길동',33);

1 개의 행이 만들어졌습니다.

SQL> insert into gaip(id,pass,name,age)
  2  values('sung','dan','성춘향',20);

1 개의 행이 만들어졌습니다.

 

SQL> select * from gaip;

ID             PASS           NAME                        AGE
-------------- -------------- --------------------

junho1         1234             이준호                       18
hana           1111               이하나                     17
hong           aaaa              홍길동                      33
sung           dan                성춘향                     20

 

 

#. select(데이타 검색)

SQL> select * from gaip
  2  where age>=20;

ID             PASS           NAME                        AGE
-------------- -------------- --------------------

hong           aaaa           홍길동                         33
sung           dan              성춘향                       20

 

SQL> select id, name from gaip;

ID             NAME
-------------- --------------------
junho1         이준호
hana           이하나
hong           홍길동
sung           성춘향

 

SQL> select pass from gaip
  2  where id='hong';

PASS
--------------
aaaa

 

 

#. update(데이터 수정)

SQL> update gaip set age=90
  2  where id='sung';

1 행이 갱신되었습니다.

SQL> select * from gaip;

ID             PASS           NAME                        AGE
-------------- -------------- --------------------

junho1         1234           이준호                       18
hana           1111           이하나                       17
hong           aaaa          홍길동                       33
sung           dan            성춘향                       90

 

SQL> update gaip set pass='a1234'
  2  where name='홍길동';

1 행이 갱신되었습니다.

SQL> select * from gaip;

ID             PASS           NAME                        AGE
-------------- -------------- --------------------

junho1         1234            이준호                       18
hana           1111            이하나                       17
hong           a1234          홍길동                       33
sung           dan             성춘향                       90

 

SQL> update gaip set age=age+10
  2  where age<20;

2 행이 갱신되었습니다.

SQL> select * from gaip;

ID             PASS           NAME                        AGE
-------------- -------------- --------------------

junho1         1234           이준호                       28
hana           1111           이하나                       27
hong           a1234         홍길동                       33
sung           dan            성춘향                       90

 

 

#. delete(데이타 삭제)

SQL> delete from gaip
  2  where id='junho1';

1 행이 삭제되었습니다.

SQL> select * from gaip;

ID             PASS           NAME                        AGE
-------------- -------------- -------------------- -

hana           1111                이하나                      27
hong           a1234              홍길동                      33
sung           dan                 성춘향                      90

 

 

'DB(SQL)' 카테고리의 다른 글

[MySQL] MySQL 접속  (0) 2013.07.08
조인(Join)  (0) 2012.07.27
사용자 생성, 권한부여, 삭제  (0) 2012.07.27
SQL문의 종류 - DDL, DML, DCL  (0) 2012.07.27
테이블 생성과 삭제  (0) 2012.07.27