Description: I want to change column name and its data type. I have multiple columns and want to change all in one query along with their datatype.
What i tried
- Changing column type then renaming it.
ALTER TABLE customers ALTER COLUMN phone TYPE numeric
RENAME COLUMN phone TO contact_phone
and
ALTER TABLE customers ALTER COLUMN phone TYPE numeric,
RENAME COLUMN phone TO contact_phone
- Changing multiple column type then renaming it.
ALTER TABLE customers
ALTER COLUMN phone TYPE numeric,
ALTER COLUMN address TYPE text,
RENAME COLUMN phone TO contact_phone,
RENAME COLUMN address TO contact_address
- Tried to change all column data type then rename it
ALTER TABLE customers
ALTER COLUMN phone TYPE numeric,ALTER COLUMN address TYPE text
and
ALTER TABLE customers
RENAME COLUMN phone TO contact_phone,RENAME COLUMN address TO contact_address
Issue:
Each time I am getting an error in the RENAME clause which is
SQL State : 42601
Can anyone tell me what is wrong with this query?