주석
-- 한줄 주석
/*
문장 주석
*/
CREATE (생성)
CREATE DATABASE database_name;
DROP (삭제)
DROP DATABASE database_name;
BACKUP (백업)
BACKUP DATABASE database_name TO DISK = 'filepath'
CREATE TABLE (테이블 생성)
CREATE TABLE table_name (
column1 datatype constraint, /* constraint: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK, DEFAULT, INDEX */
column2 datatype constraint,
....
);
CREATE TABLE new_table_name AS
SELECT column1, column2,...
FROM table_name
WHERE conditions;
DROP TABLE (테이블 삭제)
DROP TABLE table_name;
TRUNCATE TABLE (데이터 삭제)
TRUNCATE TABLE table_name;
ALTER TABLE (컬럼 추가, 삭제, 수정)
/* 컬럼 추가 */
ALTER TABLE table_name
ADD column_name datatype;
/* 컬럼 삭제 */
ALTER TABLE table_name
DROP COLUMN column_name;
/* 컬럼 수정 */
ALTER TABLE table_name
ALTER COLUMN column_name datatype; /* MS SQL */
MODIFY COLUMN column_name datatype; /* MySQL */
MODIFY column_name datatype; /* ORACLE */
반응형
댓글