06-17-2019 08:10 PM
Hi.
I was trying to rename my table by query.
So I found 'ALTER TABLE old_table_name RENAME TO new_table_name;' query on the internet.
But it cause error.
I try other functions like
ALTER TABLE name DROP [COLUMN] column_name
ALTER TABLE name ADD COLUMNS
and it work fine.
I don't know why I can't change my Table by 'ALTER' statement.
Is there anybody know the reason?
06-18-2019 06:20 AM
Try sp_rename
06-18-2019 06:32 AM - edited 06-18-2019 06:35 AM
It would be useful to know the error...
What database are you using? Apparently MySQL uses a different syntax.
06-18-2019 07:21 AM
I’m working with Access.
06-18-2019 07:26 AM
"
Note
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. Use the DAO Create methods instead."
/Y
06-18-2019 07:29 AM
You can Select everything and drop it into a new table, then drop the old, that'd effectively be a rename.
SELECT *
INTO [acecodetable].['PSCLineReason']
FROM [acecodetable].['15_PSCLineReason'];
DROP [acecodetable].['15_PSCLineReason']
/Y
06-18-2019 07:30 AM
Apparently Access doesn't support a single query to do that:
06-18-2019 07:54 PM - edited 06-18-2019 07:55 PM
So there No way to Rename the Table by ALTER Query.
Thanks guys