Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALTER TABLE t RENAME COLUMN a to b;

Status
Not open for further replies.

jmodo

Programmer
Aug 2, 2006
43
US
I can't get this to work. Is there a way to rename a column through sql in Access?

Thanks,
J.
 
This may be of interest:
alter table method to rename a table field
thread701-908514
 
It looks like rename is not supported.
I am trying to create a new column, copy the data over, and then drop the old column(primary key).
How do I copy the data from one column to the next, and how do I drop a column that is the primary key?

Thanks.
 
You seriously want to rename the Primary Key ?
Who cares the internal names of your fields ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I know it isn't probably the best idea, but I don't see anything linking to it, plus there is another key that really acts as the primary key. (I didn't develop the database) I made some other changes to the access database already that rely on this change.
 

Guess you could
Code:
ALTER TABLE myTable ADD COLUMN NewColumn Text (50)
followed by
Code:
UPDATE myTable SET NewColumn = OldColumn
And
Code:
ALTER TABLE myTable DROP INDEX PrimaryKey
finally
Code:
CREATE INDEX PrimaryKey ON myTable (ActsAsPrimary) WITH PRIMARY
 
I can't get the "DROP INDEX PrimaryKey" to work. I am using Access, and I don't see any INDEX name just the field.
I'd like to drop the autonumber from the [id] field, and add it to another field [newField]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top