SQL DEFAULT

DEFAULT constraint is used to set a default value to a column.

If you do not specify a value to insert a row, then can the default value (DEFAULT) having each column.

SQL DEFAULT in the CREATE TABLE

CREATE TABLE orders { orderid int, int product, int quantity, orderdate date DEFAULT GETDATE() }

If you created an order, we do not specify the value of the column 'date', then for that column will be inserted by default to execute the function obtained GETDATE (), which returns the system date

Instead of a function, we can insert a specific value '2001-01-01 'or any other value.

SQL DEFAULT in the ALTER TABLE for MySQL

ALTER TABLE orders ALTER orderdate DEFAULT 2012-01-01

SQL DEFAULT in the ALTER TABLE statement to ORACLE, SQLSERVER, ACCESS:

ALTER TABLE orders ALTER COLUMN orderdate SET DEFAULT 2012-01-01

To delete DEFAULT in MySQL

ALTER TABLE orders ALTER orderdate DROP DEFAULT

To delete DEFAULT in ORACLE, SQLSERVER, ACCESS:

ALTER TABLE orders ALTER COLUMN orderdate DROP DEFAULT