The 1.DEFAULT constraint is used to insert a default value into a column.
CREATE TABLE Orders
(
Id_o int not NULL,
OrderNo int not NULL,
id_p int,
OrderDate date DEFAULT GETDATE ()
)
2. Create a DEFAULT constraint for the "City" column if the table already exists
ALTER TABLE Persons
ALTER COLUMN City SET DEFAULT ' Sandnes '
Revoke
ALTER TABLE Persons
ALTER COLUMN City DROP DEFAULT
3.CREATE INDEX Instance
This session creates a simple index, named "Personindex," in the LastName column of the person table:
If you want to index more than one column, you can list the names of these columns in parentheses, separated by commas:
CREATE INDEX personindexon person (LastName, FirstName)
4. Add a column
ALTER TABLE Personsalter COLUMN Birthday Year
Note that the data type of the "Birthday" column is year, which can hold 2-bit or 4-bit formats .
SQL Beginner Tutorial Study (v)