alter column name postgres code example

Example 1: how to update column name in psql

ALTER TABLE table_name
  RENAME COLUMN old_name TO new_name;

Example 2: psql filed name alter

ALTER TABLE table_name 
RENAME column_name TO new_column_name;

Example 3: rename column postgres

ALTER TABLE customers 
RENAME COLUMN name TO customer_name;

ALTER TABLE customers
RENAME COLUMN phone TO contact_phone;

Example 4: postgres how to add field created at

CREATE TABLE my_table
(
	id serial NOT NULL,
    user_name text,
	created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP //here
)

Example 5: rename column postgres

ALTER TABLE distributors RENAME COLUMN address TO city;

Example 6: how to update column name in psql

ALTER TABLE order_details
  DROP COLUMN notes;

Tags:

Html Example