![]() In this example, you do not have to list the EmployeeID field after the Employees table in the REFERENCES clause because EmployeeID is the primary key of the Employees table. The foreign key is based on the EmployeeID field and refers to the EmployeeID field of the Employees table. This example adds a foreign key to the Orders table. ' Delete the Salary field from the Employees table. This example removes the Salary field from the Employees table. ' Modify the existing Salary field of the Employees table This example changes the Salary field from the data type Money to the data type Char. ' Add the Salary field to the Employees table ' Modify this line to include the path to Northwind This example adds a Salary field with the data type Money to the Employees table. Attempting to apply this restriction more than once restuls in a run-time error. However, you can apply the NOT NULL restriction only once to a field. ![]() You can use NOT NULL on a single field or within a named CONSTRAINT clause that applies to either a single field or to a multiple-field named CONSTRAINT.You can use the CREATE INDEX statement to add a single- or multiple-field index to a table, and you can use ALTER TABLE or the DROP statement to delete an index created with ALTER TABLE or CREATE INDEX.You cannot add or delete more than one field or index at a time.You specify only the index name following the CONSTRAINT reserved word. Use DROP CONSTRAINT to delete a multiple-field index. For more information about multiple-field indexes, see CONSTRAINT clause. Use ADD CONSTRAINT to add a multiple-field index. For example, the following statement changes the data type of a field in the Employees table called ZipCode (originally defined as Integer) to a 10-character Text field: ALTER TABLE Employees ALTER COLUMN ZipCode TEXT(10) You specify the field name, the new data type, and an optional size for Text and Binary fields. Use ALTER COLUMN to change the data type of an existing field. If you specify NOT NULL for a field, new records are required to have valid data in that field. ![]() For more information about single-field indexes, see CONSTRAINT clause. You can also define an index on that field. For example, the following statement adds a 25-character Text field called Notes to the Employees table: ALTER TABLE Employees ADD COLUMN Notes TEXT(25) You specify the field name, data type, and (for Text and Binary fields) an optional size. ![]() Use ADD COLUMN to add a new field to the table. ![]() The name of the multiple-field index to be removed.īy using the ALTER TABLE statement, you can alter an existing table in several ways. For more information about how to construct this index, see CONSTRAINT clause. The definition of a multiple-field index to be added to table. The field size in characters (Text and Binary fields only). Or, the name of the field to be altered in table. The name of the field to be added to or deleted from table. The ALTER TABLE statement has these parts: The Microsoft Access database engine does not support the use of ALTER TABLE, or any of the data definition language (DDL) statements, with non-Microsoft Access databases. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |