Below is the syntax for adding default constraint for an existing table
ALTER TABLE tbl_Name
ADD CONSTRAINT default_columnName
DEFAULT value FOR columnNmae
example :
Below is the query to create DEFAULT constraint on qty column when the orderqty table already created
ALTER TABLE orderqty
ADD CONSTRAINT default_qty
DEFAULT 1 FOR qty;
We created default constraint and we did not inserted value for qty field using INSERT statement in below example but "1" value inserted for qty
ALTER TABLE tbl_Name
ADD CONSTRAINT default_columnName
DEFAULT value FOR columnNmae
example :
Below is the query to create DEFAULT constraint on qty column when the orderqty table already created
ALTER TABLE orderqty
ADD CONSTRAINT default_qty
DEFAULT 1 FOR qty;
We created default constraint and we did not inserted value for qty field using INSERT statement in below example but "1" value inserted for qty
No comments:
Post a Comment