B
bluesea07
Unregistered / Unconfirmed
GUEST, unregistred user!
不好意思有最后10分了,请多帮忙
Analysis
This statement adds a column named vend_phone to the Vendors table. The datatype must be specified.
Other alter operations, for example, changing or dropping columns, or adding constraints or keys, use a similar syntax. (Note that the following example will not work with all DBMSs):
Input
ALTER TABLE Vendors
DROP COLUMN vend_phone;
Complex table structure changes usually require a manual move process involving these steps:
_Create a new table with the new column layout.
_Use the INSERT SELECT statement (see Lesson 15, "Inserting Data," for details of this statement) to copy the data from the old table to the new table. Use conversion functions and calculated fields, if needed.
_Verify that the new table contains the desired data.
_Rename the old table (or delete it, if you are really brave).
_Rename the new table with the name previously used by the old table.
Recreate any triggers, stored procedures, indexes, and foreign keys as needed.
Use ALTER TABLE Carefully Use ALTER TABLE with extreme caution, and be sure you have a complete set of backups (both schema and data) before proceeding. Database table changes cannot be undone—and if you add columns you don't need, you might not be able to remove them. Similarly, if you drop a column that you do need, you might lose all the data in that column.
Analysis
This statement adds a column named vend_phone to the Vendors table. The datatype must be specified.
Other alter operations, for example, changing or dropping columns, or adding constraints or keys, use a similar syntax. (Note that the following example will not work with all DBMSs):
Input
ALTER TABLE Vendors
DROP COLUMN vend_phone;
Complex table structure changes usually require a manual move process involving these steps:
_Create a new table with the new column layout.
_Use the INSERT SELECT statement (see Lesson 15, "Inserting Data," for details of this statement) to copy the data from the old table to the new table. Use conversion functions and calculated fields, if needed.
_Verify that the new table contains the desired data.
_Rename the old table (or delete it, if you are really brave).
_Rename the new table with the name previously used by the old table.
Recreate any triggers, stored procedures, indexes, and foreign keys as needed.
Use ALTER TABLE Carefully Use ALTER TABLE with extreme caution, and be sure you have a complete set of backups (both schema and data) before proceeding. Database table changes cannot be undone—and if you add columns you don't need, you might not be able to remove them. Similarly, if you drop a column that you do need, you might lose all the data in that column.