Click to See Complete Forum and Search --> : SQL Question
rodders45
Dec 22nd, 2000, 12:42 PM
How, using SQL, do you insert a new field into a table in an Access database which already exists without deleting the table and creating a new one?
parksie
Dec 22nd, 2000, 01:18 PM
Use ALTER TABLE.
rodders45
Dec 23rd, 2000, 08:48 AM
How exactly do you use ALTER TABLE?
parksie
Dec 23rd, 2000, 10:53 AM
This is from the documentation:
ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
or ADD [COLUMN] (create_definition, create_definition,...)
or ADD INDEX [index_name] (index_col_name,...)
or ADD PRIMARY KEY (index_col_name,...)
or ADD UNIQUE [index_name] (index_col_name,...)
or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
or CHANGE [COLUMN] old_col_name create_definition
or MODIFY [COLUMN] create_definition
or DROP [COLUMN] col_name
or DROP PRIMARY KEY
or DROP INDEX index_name
or RENAME [AS] new_tbl_name
or table_options
So to add a field:
ALTER TABLE <table> ADD COLUMN (<type>)
rodders45
Dec 24th, 2000, 09:01 AM
cheers :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.