DEFAULT
SQL DEFAULT constraints in CREATE TABLE
The following SQL creates DEFAULT in the column "City, when creating a table" Persons ":
My SQL / SQL Server / Oracle / MS Access:
1 2 3 4 5 6 7 |
CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255) DEFAULT 'Sandnes' ) |
1 2 3 4 5 6 |
CREATE TABLE Orders ( O_Id int NOT NULL, OrderNo int NOT NULL, P_Id int, OrderDate date DEFAULT GETDATE() ) |
SQL DEFAULT Restrictions on ALTER TABLE
The following SQL creates DEFAULT in the column "City, when the table" Persons "has already been established:
MySQL:
SQL Server / Oracle / MS Access:
Removing DEFAULT
To remove a constraint DEFAULT, use the following SQL:
MySQL:
SQL Server / Oracle / MS Access:
SQL Default





Comments