[MySQL] 기본 명령어 - 필드 추가, 수정, 삭제

▒▒▒ MYSQL 기본명령어 - 여러가지명령어 ▒▒▒

테이블구조를 정해놓고 설명하겠습니다.
-- 테이블 NAME : TEST --
---------------------------------------------
필드이름   |   타입
---------------------------------------------
id            |    int(11) auto_increment not null
name       |   varchar(10)
email       |   varchar(30)
---------------------------------------------


▒▒ INSERT : 레코드를 삽입하는 명령어입니다.
ex) insert into test values (' ','송윤경','leopit@korea.com');
ex) insert into test id,name values(' ','송윤경');

▒▒ UPDATE : 데이터를 업데이트합니다.
ex) update test set name='홍지현' where id=1;
ex) update test set name='홍지현' where name='송윤경';

▒▒ DELETE : 레코드를 삭제합니다.
ex) delete from test where id=1;
ex) delete from test where name='송윤경';

▒▒ DROP : 테이블을 삭제합니다.
ex) drop table test;

▒▒ ALTER : 각종정보를 수정합니다.
-- 테이블이름 수정 --
ex) alter table test rename test1; 
ex) rename table test to test1;  
// test 란 테이블 이름을 test1 으로 바꿉니다.

-- 필드추가 --
ex) alter table test add content text  // content 란 필드를 추가합니다.

-- 필드삭제 --
ex) alter table test drop content   // content 필드를 삭제합니다.

-- 필드이름 수정 --
ex) alter table test change name myname   // name 필드를 myname으로 수정합니다.

-- 필드타입 수정 --
ex) alter table test modify name varchar(30)   // name 필드를 타입을 varchar(30)으로 바꿉니다. 


출처 : http://leopit.com

이 글과 관련있는 글을 자동검색한 결과입니다 [?]

Creative Commons License

by 델피니 | 2008/09/18 12:45 | ┃ 기타 프로그래밍 | 트랙백 | 덧글(0)

트랙백 주소 : http://delpini.egloos.com/tb/2031813
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]

:         :

:

비공개 덧글

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