my sql 다운로드 버전
my sql 5.7.32 64비트
work bench 아무거나
ODBC 5.3.9
테이블을 생성하고 변경제거하는 기능을 제공
-create/alter/drop..
테이블에 새 데이터를 삽입하거나, 테이블에 저장된 데이터를 수정,삭제,검색하는 기능을 제공
-select/insert/update/delete
보안을 위해 데이터에 대한 접근 및 사용권한을 사용자 별로 부여하거나 취소하는 기능을 제공
NOT NULL : 공백을 허용하지 않음
DEFAULT : 기본 값을 지정하는 키워드
Primary key : 기본 키를 지정하는 키워드
unique : 대체키를 지정하는 키워드
Foreign key : 외래키를 지정하는 키워드
Constraint : 특정 제약사항 및 조건을 지정
create database test;
use test;
create table customer ( id varchar(20) not null, c_name varchar(10) not null, age int, c_level varchar(10) not null,
job varchar(20), c_point int default 0, primary key(id));
drop table customer;
select * from customer;
create table product (num char(3) not null, p_name varchar(20), stock int, price int, factory varchar(20),
primary key(num), check (stock>=0 and stock<=10000));
alter table customer add day_in date;
alter table customer drop column day_in;
alter table customer add constraint chk_age check (나이>=20);
insert into customer (id,c_name,age,c_level,job,c_point)
values("apple","정소화",20,"gold","학생",1000);
select num, stock, factory from product;
select distinct factory from product;
Select p_name, price as 가격 from product;
select p_name, price+2000 as '조정 단가' from product;
select p_name, stock, price from product where factory="욤욤식품";
select order_product, qnt, order_day from order where order_customer="apple" and/or qnt>=15;
update product set p_name="존맛만두" where p_name="p01";
update product set price=price*1.1;
update order set qnt=5 where order_customer in (select id from customer where c_name="정소화");
-->order 테이블의 qnt를 'customer테이블에서 c_name이 정소화인 고객의 id를 찾아서 order_cutomer와 일치하면' 5로 변경해라
delete from customer where c_name="정소화";
delete from order where order_customer in (select id from customer where c_name="정소화");