Home > OS >  How to solve syntax error with `ALTER TABLE` query?
How to solve syntax error with `ALTER TABLE` query?

Time:09-23

I’m having issues with syntax error in my queries, I’m trying to alter my table.

alter table people = person

CodePudding user response:

Looking at your question I dind't know what you were trying to rename if it was your table name or the column name.

For SQL Server to rename your column you can do this:

sp_rename 'table_name.old_column_name', 'new_column_name', 'COLUMN';

With your code should look like this:

sp_rename 'table_name.people', 'person', 'COLUMN';

Otherwise if you're trying to rename your table it will be like this:

sp_rename 'old_table_name', 'new_table_name';

With your code should look like this:

sp_rename 'people', 'person'

If you're trying to alter something else please check this document[1].

For MySQL or Oracle you can try the next document[2].

[1] https://www.w3schools.com/sql/sql_alter.asp

[2]https://www.geeksforgeeks.org/sql-alter-rename/

  •  Tags:  
  • sql
  • Related