Computer Science/Database

W3Schools SQL | #49 SQL DEFAULT CONSTRAINT 이용법

토마토. 2022. 10. 30. 00:03

SQL DEFAULT Constraint

SQL DEFAULT Constraint

column 값의 디폴트 값을 설정한다.

SQL DEFAULT on CREATE TABLE

CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int, 
    City varchar(255) DEFAULT 'Sandnes'
);

SQL DEFAULT on ALTER TABLE

ALTER TABLE Persons
ALTER City SET DEFAULT 'Sandnes';

DROP a DEFAULT Constraint

ALTER TABLE Persons
ALTER City DROP DEFAULT;