Database Reference
In-Depth Information
Figure 4.10
Use stored procedure to obtain table deinition.
ALTER TABLE SHIPPING ADD
CONSTRAINT Shipping_EmployeeID_fk
FOREIGN KEY (EmployeeID)
REFERENCES EMPLOYEE (EmployeeID)
To add a check constraint to the column Qoh in the INVENTORY table, use
ALTER TABLE INVENTORY ADD
CONSTRAINT Inventory_ck CHECK(Qoh >= 0)
With the ALTER TABLE constraint, you can also add and delete columns in a table. For
example, if you want to add a column ShelfID to the table INVENTORY, use the following
code:
ALTER TABLE INVENTORY ADD ShelfID INT
You can also delete the column ShelfID from the table INVENTORY with the following
code:
ALTER TABLE INVENTORY Drop COLUMN ShelfID
he ALTER TABLE keyword phrase can also be used to change the data type of the column.
For example, if you want to change the data type of the column Qoh from INT to BIGINT, use
the following SQL statement:
ALTER TABLE INVENTORY ALTER COLUMN Qoh BIGINT
When changing the column properties, make sure that the column is not used by constraints
and referenced by other columns. For example, the column Qoh in the above code has a domain
Search WWH ::




Custom Search