CREATE DATABSE
Write the correct SQL statement to create a new database called testDB.
CREATE DATABASE testDB;
DROP DATABASE
Write the correct SQL statement to delete a database named testDB.
DROP DATABASE testDB;
CREATE TABLE
Write the correct SQL statement to create a new table called Persons.
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
DROP TABLE
Write the correct SQL statement to delete a table called Persons.
DROP TABLE Persons;
ALTER TABLE
기존 테이블에서 열을 추가, 삭제 또는 수정. 기존 테이블에 다양한 제약조건을 추가 및 삭제하는데도 사용.
ALTER TABLE table_name
ADD column_name datatype;
or
ALTER TABLE table_name
DROP COLUMN column_name;
or
ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
TRUNCATE TABLE
Use the TRUNCATE statement to delete all data inside a table.
TRUNCATE TABLE Persons;
Add a column of type DATE called Birthday.
ALTER TABLE Persons
ADD Birthday DATE
;
Delete the column Birthday from the Persons table.
ALTER TABLE Persons
DROP COLUMN Birthday;
SQL 제약
프로그래머스 sql문제 뽀개기
새로알게 된 개념
w3school | HAVING 절
w3school | IFNULL
w3school | IF
w3school | Case
w3school | DATE_FORMAT()