💡 데이터 조작문에 대해 공부해보자
insert into board values (1, '첫번째 글', 'aaa', '관리자', '2021-11-24', 0);
insert into 테이블이름(title, content, author, wr_date) value('두번째 글', 'bbb', '홍길동', '2021-11-24');
insert into Address(Address1, Address2, Address3, Postal_Code, Client_ID)
value ('서울특별시', '강남구 삼성동 44번지', 'A아파트 1동 101호', 50693, '321'),
('경기도', '성남시 분당구 정자동 66번지', 'B아파트 5동 111호', 12301, '441'),
('서울특별시', '강남구 삼성동 64길', 'C아파트 3동 190호', 50693, '216'),
('경기도', '성남시 분당구 정자동 44길', 'D아파트 5동 111호', 12301, '435');
select idx, title from board;
select distinct title from board;
select title as '제목', content as '내용' from board;
select * from board where idx=1;
select title, content from board where idx=1;
select * from board where author='관리자';
select * from board where idx in(1, 3, 5);
select * from board where idx between 1 and 3;
select * from board where idx between '2021-11-22' and '2021-11-24';
select * from board order by idx desc;
select * from board where idx in(1, 3, 5) order by idx desc;
update Address set Address1='서울특별시' where SEQ_ID=2;
delete from board;
delete from board where idx in (1,3,5);
delete from Address where Address1='경기도';
show databases;
use 데이터베이스명;
show tables;
create table Address (
SEQ_ID int primary key not null auto_increment,
Address1 varchar(10) not null,
Address2 varchar(50) not null,
Address3 varchar(50) not null,
Postal_Code char(5) not null,
Client_ID char(3) not null
);
desc 테이블명
insert into Address(Address1, Address2, Address3, Postal_Code, Client_ID) value
(‘서울특별시’, ‘강남구 삼성동 44번지’, ‘A아파트 1동 101호’, 50693, ‘321’);
insert into Address(Address1, Address2, Address3, Postal_Code, Client_ID) value
(‘서울특별시’, ‘강남구 삼성동 44번지’, ‘A아파트 1동 101호’, 50693, ‘321’),
(‘경기도’, ‘성남시 분당구 정자동 66번지’, ‘B아파트 5동 111호’, 12301, ‘441’),
(‘서울특별시’, ‘강남구 삼성동 64길’, ‘C아파트 3동 190호’, 50693, ‘216’),
(‘경기도’, ‘성남시 분당구 정자동 44길’, ‘D아파트 5동 111호’, 12301, ‘435’);
update Address set Address1=‘서울특별시’ where SEQ_ID=2;
delete from Address where Address1=‘경기도’;