DEFAULT
Ograniczenia DEFAULT w SQL CREATE TABLE
Następujące SQL tworzy DEFAULT w kolumnie "Miasto, podczas tworzenia tabeli" Osoby ":
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' ) |
Ograniczenie DEFAULT może być również funkcja, na przykład GETDATE ():
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() ) |
Ograniczenia SQL DEFAULT na ALTER TABLE
Następujące SQL tworzy DEFAULT w kolumnie "Miasto, gdy stół" Osoby "ma już ustalone:
MySQL:
SQL Server / Oracle / MS Access:
Usuwanie DEFAULT
Aby usunąć DEFAULT ograniczenie, wykonaj następujące SQL:
MySQL:
SQL Server / Oracle / MS Access:
Domyślnie SQL





Komentarze