CRUD(advanced)
Udemy The Ultimate MySQL Bootcamp Section 6를 복습하며 작성한 쿼리문입니다.
CREATE DATABASE shirts_db;
USE shirts_db;
CREATE TABLE shirts
(
shirt_id INT NOT NULL AUTO_INCREMENT,
article VARCHAR(100),
color VARCHAR(100),
shirt_size VARCHAR(100),
last_worn INT,
PRIMARY KEY(shirt_id)
);
//CREATE
INSERT INTO shirts(article, color, shirt_size, last_worn) VALUES
('t-shirt', 'white', 'S', 10),
('t-shirt', 'green', 'S', 200),
('polo shirt', 'black', 'M', 10),
('tank top', 'blue', 'S', 50),
('t-shirt', 'pink', 'S', 0),
('polo shirt', 'red', 'M', 5),
('tank top', 'white', 'S', 200),
('tank top', 'blue', 'M', 15)
INSERT INTO shirts (color, article, shirt_size, last_worn) values ('purple', 'polo shirt', 'M', 50);
//READ
SELECT article, color, shirt_size, last_worn FROM shirts WHERE shirt_size='M';
//UPDATE
UPDATE shirts SET shirt_size='L' WHERE article='polo shirt';
UPDATE shirts SET last_worn=0 WHERE last_worn=15;
UPDATE shirts SET shirt_size='XS', color='off white' WHERE color='white';
//DELETE
DELETE FROM shirts WHERE last_worn=200;
DELETE FROM shirts WHERE article='tank top';
DELETE FROM shirts;
DROP TABLE shirts;
Author And Source
이 문제에 관하여(CRUD(advanced)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@kaitlin_k/sql-CRUDadvanced저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)