Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

SQL Auto Increment Primary Key - PostgreSQL

-- SERIAL keyword auto increments the value
CREATE TABLE Colleges (
  college_id INT SERIAL,
  college_code VARCHAR(20) NOT NULL,
  college_name VARCHAR(50),
  CONSTRAINT CollegePK PRIMARY KEY (college_id)
);

-- inserting record without college_id
INSERT INTO Colleges(college_code, college_name)
VALUES ("ARD13", "Star Public School");
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #SQL #Auto #Increment #Primary #Key #PostgreSQL
ADD COMMENT
Topic
Name
2+3 =