skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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;

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search