Search

DDL.sql μ‹€ν–‰

/* * ν…Œμ΄λΈ” * user * persistent_logins * product * product_io * order */ -- μ™Έλž˜ν‚€ μ œμ•½μ‘°κ±΄ μ‚­μ œ --ALTER TABLE product_io DROP FOREIGN KEY product_id_FK; --ALTER TABLE product_io DROP FOREIGN KEY order_no_FK; -- νšŒμ› ν…Œμ΄λΈ” DROP TABLE IF EXISTS `user` CASCADE; create table `user` ( id varchar(10) not null COMMENT 'νšŒμ› 아이디', -- νšŒμ› 아이디 password varchar(10) not null COMMENT 'λΉ„λ°€λ²ˆν˜Έ', -- λΉ„λ°€λ²ˆν˜Έ name varchar(10) not null COMMENT '이름', -- 이름 gender varchar(5) COMMENT '성별', -- 성별 birth varchar(10) COMMENT '생일', -- 생일 mail varchar(30) COMMENT '메일', -- 메일 phone varchar(20) COMMENT 'μ „ν™”λ²ˆν˜Έ', -- μ „ν™”λ²ˆν˜Έ address varchar(90) COMMENT 'μ£Όμ†Œ', -- μ£Όμ†Œ regist_day timestamp default now() COMMENT 'κ°€μž…μΌμž', -- κ°€μž…μΌμž primary key(id) ) COMMENT 'νšŒμ›'; INSERT INTO `user` (id, password, name) VALUES ('joeun', '123456', '김쑰은'); -- μžλ™ 둜그인 ν…Œμ΄λΈ” DROP TABLE IF EXISTS `persistent_logins` CASCADE; CREATE TABLE `persistent_logins` ( `p_no` int NOT NULL AUTO_INCREMENT COMMENT 'μžλ™ 둜그인 번호', `user_id` varchar(255) NOT NULL COMMENT 'νšŒμ› 아이디', `token` varchar(255) NOT NULL COMMENT '토큰', `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'λ“±λ‘μΌμž', PRIMARY KEY (`p_no`), UNIQUE KEY `unique_token` (`token`) ) COMMENT 'μžλ™ 둜그인'; -- μƒν’ˆ ν…Œμ΄λΈ” DROP TABLE IF EXISTS `product` CASCADE; CREATE TABLE product ( product_id varchar(100) NOT NULL COMMENT 'μƒν’ˆID', name varchar(100) NOT NULL COMMENT 'μƒν’ˆλͺ…', unit_price INT NULL COMMENT '가격(단가)', description TEXT NULL COMMENT 'μ„€λͺ…', manufacturer varchar(100) NULL COMMENT 'μ œμ‘°μ—…μ²΄', category varchar(100) NULL COMMENT 'μΉ΄ν…Œκ³ λ¦¬', units_in_stock INT DEFAULT 0 NOT NULL COMMENT '재고 수', `condition` varchar(100) NULL COMMENT 'μƒνƒœ', file TEXT NULL COMMENT '파일경둜', quantity INT DEFAULT 0 NOT NULL COMMENT 'μž₯λ°”κ΅¬λ‹ˆ 개수', CONSTRAINT product_pk PRIMARY KEY (product_id) ) COMMENT 'μƒν’ˆ'; INSERT INTO product (product_id, name, unit_price, description, manufacturer, category, units_in_stock, `condition`, file) VALUES('P100001', 'μžλ°” ν”„λ‘œκ·Έλž˜λ°', 50000, 'μ•ˆλ…•ν•˜μ„Έμš” μžλ°”ν”„λ‘œκ·Έλž˜λ° κ°•μ˜μž…λ‹ˆλ‹€.', 'μ•Œλ‘œν•˜ν΄λž˜μŠ€', 'κ°•μ˜', 100, 'NEW', '/static/img/JAVA.jpg'); INSERT INTO product (product_id, name, unit_price, description, manufacturer, category, units_in_stock, `condition`, file) VALUES('P100002', '였라클 λ°μ΄ν„°λ² μ΄μŠ€', 20000, '였라클 λ°μ΄ν„°λ² μ΄μŠ€ μž…λ‹ˆλ‹€.', 'μ•Œλ‘œν•˜ν΄λž˜μŠ€', 'κ°•μ˜', 100, 'NEW', '/static/img/DB.jpg'); INSERT INTO product (product_id, name, unit_price, description, manufacturer, category, units_in_stock, `condition`, file) VALUES('P100003', 'HTML CSS JAVASCRIPT', 15000, 'μ›Ή 기초 κ°•μ˜μž…λ‹ˆλ‹€.', 'μ•Œλ‘œν•˜ν΄λž˜μŠ€', 'κ°•μ˜', 100, 'NEW', '/static/img/WEB.jpg'); INSERT INTO product (product_id, name, unit_price, description, manufacturer, category, units_in_stock, `condition`, file) VALUES('P100004', 'JSP', 80000, 'JSP κ°•μ˜μž…λ‹ˆλ‹€.', 'μ•Œλ‘œν•˜ν΄λž˜μŠ€', 'κ°•μ˜', 100, 'NEW', '/static/img/JSP.jpg'); -- μ£Όλ¬Έ ν…Œμ΄λΈ” DROP TABLE IF EXISTS `order` CASCADE; CREATE TABLE `order` ( `order_no` int NOT NULL AUTO_INCREMENT COMMENT '주문번호', `ship_name` varchar(100) NOT NULL COMMENT 'λ°›λŠ”μ‚¬λžŒμ΄λ¦„', `zip_code` varchar(100) NOT NULL COMMENT '우편번호', `country` varchar(100) NOT NULL COMMENT 'κ΅­κ°€', `address` varchar(200) NOT NULL COMMENT 'μ£Όμ†Œ', `date` varchar(200) NOT NULL COMMENT 'λ°°μ†‘μΌμž', `order_pw` varchar(200) NULL COMMENT 'μ£Όλ¬Έ λΉ„λ°€λ²ˆν˜Έ', `user_id` varchar(10) DEFAULT NULL COMMENT 'νšŒμ›μ•„μ΄λ””', `total_price` int DEFAULT '0' COMMENT '총가격', `phone` varchar(20) DEFAULT NULL COMMENT 'λΉ„νšŒμ› μ „ν™”λ²ˆν˜Έ', PRIMARY KEY (`order_no`) ) COMMENT='μ£Όλ¬Έ'; -- μž…μΆœκ³  ν…Œμ΄λΈ” DROP TABLE IF EXISTS `product_io` CASCADE; CREATE TABLE `product_io` ( `io_no` int NOT NULL AUTO_INCREMENT COMMENT 'μž…μΆœκ³ λ²ˆν˜Έ', `product_id` varchar(100) NOT NULL COMMENT 'μƒν’ˆμ•„μ΄λ””', `order_no` int DEFAULT NULL COMMENT '주문번호', `amount` int DEFAULT NULL COMMENT 'μž…μΆœκ³ λŸ‰', `type` varchar(100) DEFAULT NULL COMMENT 'μž…κ³ (IN),좜고(OUT)', `io_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'μž…μΆœκ³ λ‚ μ§œ', `user_id` varchar(10) DEFAULT NULL COMMENT 'νšŒμ›μ•„μ΄λ””', PRIMARY KEY (`io_no`), KEY `product_id_FK` (`product_id`), KEY `product_id_FK_1` (`order_no`), CONSTRAINT `product_id_FK` FOREIGN KEY (`product_id`) REFERENCES `product` (`product_id`), CONSTRAINT `order_no_FK` FOREIGN KEY (`order_no`) REFERENCES `order` (`order_no`) ) COMMENT='μƒν’ˆ μž…μΆœκ³ ';
SQL
볡사