[SQLD] ALTER TABLE ~
Database/SQL
2024. 5. 15. 19:03
1. 기존 테이블에 새로운 컬럼 추가
- 단일 컬럼 추가할 때는 ADD 뒤에 괄호를 생략 가능
ALTER 테이블명 ADD 컬럼명 데이터타입 [DEFAULT 기본값] [CONSTRAINT 제약조건명 PRIMARY KEY (컬럼명)];
- 여러 개 컬럼 추가할 때는 ADD 뒤에 괄호가 필요
ALTER 테이블명 ADD (컬럼명1 데이터타입 [DEFAULT 기본값], 컬럼명1 데이터타입 [DEFAULT 기본값]...);
2. 기존 테이블에서 컬럼 삭제
ALTER 테이블명 DROP COLUMN 컬럼명;
3. 기본키 추가
ALTER 테이블 ADD CONSTRAINT 제약조건 PRIMARY KEY (컬럼);
DCL
GRANT 권한 ON 테이블 TO 부여받을사람
*GRANT로 권한 줄 때 UPDATE 등 DML 권한을 줄 때 WHERE절이 있으면 SELECT 절도 같이 권한을 줘야함
*WITH GRANT OPTION : 다른 사람에게 권한을 줄 수 있음(권한을 회수하면 다른 사람에게 준 권한도 회수됨)
'Database > SQL' 카테고리의 다른 글
[SQL] GROUP BY, HAVING, ORDER BY (0) | 2024.05.15 |
---|---|
[SQLD] 윈도우 함수 (Window Function) (0) | 2024.05.15 |
[SQLD] NULL 함수 (0) | 2024.05.15 |
[SQLD] 계층형 쿼리 (0) | 2024.05.15 |
[SQLD] 식별자 (0) | 2024.05.15 |
@서리★ :: Seory Dev
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!