alter table in postgresql code example
Example 1: postgresql add column with constraint
ALTER TABLE customers
ADD COLUMN contact_name VARCHAR NOT NULL;
Example 2: rename table postgres
ALTER TABLE table_name
RENAME TO new_table_name;
Example 3: psql drop field
ALTER TABLE table_name DROP COLUMN column_name;
Example 4: alter column in table postgres
ALTER TABLE table_name
ALTER COLUMN column_name TYPE column_definition;
Example 5: 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
)
Example 6: alter table add column postgres
Alter Postgres Table