I am trying to change column name in SQL but it is showing me error
query
alter table cust
rename column first name to first_name(30) ;
error
ERROR: syntax error at or near "name"LINE 2: rename column first name to first_name(30) ;
^SQL state: 42601Character: 38
Kindly check what we can do in this case to remove error.
2
Answers
You’re trying to remame column
first name
(Note the space)to
first_name
.first name
is not a valid column name because it contains the space.Please double-check what actual column you have in this table.
You are trying column name with spaces, that can be the issue. Try with double quotes.
ALTER TABLE cust
RENAME COLUMN “first name” TO first_name;