MS Access Create Table & Modify Table CommandsThe following Access DDL example creates a table with 2 fields: CREATE TABLE Inventory (ID Long, Description TEXT); The next example creates a new employee table with two Text fields, a Date/Time field, and a multi-field or composite primary key index using 2 fields. CREATE TABLE Employees (FirstName TEXT(20), LastName TEXT(20), dob DATETIME, If you don't specify a maximum length then Access sets text length to 255 characters. Create Table Statement SyntaxCREATE [TEMPORARY] TABLE table (field1 type [(size)] [NOT NULL] [WITH COMPRESSION | WITH COMP] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])
Example Parent Child with AUTOINCREMENTCREATE TABLE table1(id1 AUTOINCREMENT, name1 TEXT(50), CONSTRAINT table1_PK PRIMARY KEY(id1)); CREATE TABLE table2(id2 AUTOINCREMENT, id1 INT NOT NULL,
name2 TEXT(100) NOT NULL, Alter Table ExamplesALTER TABLE Employees ADD COLUMN Emp_Email TEXT(25); ALTER TABLE Article ADD COLUMN approved yesno; DROP Statement SyntaxDROP {TABLE table | INDEX index ON table} Deletes an existing table from a database or deletes an existing index from a table. The Jet engine doesn't support the use of DROP, or any of the DDL statements, with non-Microsoft Jet databases. Use the DAO Delete method instead.
|