Can tables and fields be renamed using SQL?

  • Thread starter Thread starter Laser Lu
  • Start date Start date
Help, please!

Patience please. Most of the volunteers who answer questions are in
Europe or the United States; you posted at 1:16 am and (rather
impatiently) reposted at 4:56 on a Sunday morning. I was asleep, as I
suspect most of the other volunteers were!

Yes, you can rename fields: Alter Table is the SQL syntax. I do not
believe that you can rename a table in this manner however. You can
rename either tables or fields in VBA code.

Why? Ordinarily one would create tables and leave them pretty much
fixed in design...
 
Ok, I appologize for my impatience! And thanks for your graceful answer!

You said:
Yes, you can rename fields: Alter Table is the SQL syntax.
Then can you give me the complete syntax of renaming a field using the Alter
Table statement? Or just an example, please:) Actually, I've looked it up in
the references of Jet SQL, and I didn't find the exact syntax on how to
rename a field of a table.
Why? Ordinarily one would create tables and leave them pretty much fixed
in design...
Yes, I quite agree with you. However, just as you said, 'Ordinarily' we
leave them fixed, and in my case it is unordinary.
I need to write a component which have to construct tables and add fields
automatically by the program, and also have to maintain those tables and
fields and other schema objects. So I need the solution on how to write code
to manage schema objects in a database.
 
So I need the solution on how to write code
to manage schema objects in a database.

I'd suggest working with the Tabledef object in your choice of DAO or
ADO. They both support creating and renaming tables, adding and
changing fields, etc. - the syntax is somewhat different. I'm familiar
with DAO, which works well with JET (Access .mdb) databases; but ADO
is newer and supports more backends.

Open the VBA editor and search for help on "Tabledef", and the
CreateTable and CreateField methods. If you need more specific help
post back.
 
Back
Top