Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

sql - PostgreSQL - create an auto-increment column for non-primary key

CREATE SEQUENCE mytable_item_id_seq OWNED BY mytable. item_id;
ALTER TABLE mytable ALTER item_id SET DEFAULT nextval('mytable_item_id_seq');
Source by sqlerrors.com #
 
PREVIOUS NEXT
Tagged: #sql #PostgreSQL #create #column #key
ADD COMMENT
Topic
Name
2+8 =