Search
 
SCRIPT & CODE EXAMPLE
 

SQL

pl sql auto increment

CREATE TABLE departments (
  ID           NUMBER(10)    NOT NULL,
  DESCRIPTION  VARCHAR2(50)  NOT NULL);

ALTER TABLE departments ADD (
  CONSTRAINT dept_pk PRIMARY KEY (ID));

CREATE SEQUENCE dept_seq START WITH 1;
Comment

pl sql auto increment

CREATE OR REPLACE TRIGGER dept_bir 
BEFORE INSERT ON departments 
FOR EACH ROW

BEGIN
  SELECT dept_seq.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/
Comment

PREVIOUS NEXT
Code Example
Sql :: pgadmin postgres ERROR: database is being accessed by other users 
Sql :: drop database mysql 
Sql :: coalesce function in sql server 
Sql :: sql vs nosql 
Sql :: GUI for sqlite mac 
Sql :: UNION ALL LEFT JOIN 
Sql :: sql update multiple tables 
Sql :: forgot postgres password 
Sql :: oracle ora-00054 how to unlock 
Sql :: ORACLE CALL BACK TRACE 
Sql :: hidden error sql codeigniter 3 
Sql :: view acl table oracle 
Sql :: select where mysql 
Sql :: how to limited number of rows in db2 select * from imglib FETCH FIRST 20 ROWS ONLY 
Sql :: sqlcmd no headers 
Sql :: order of execution in sql 
Sql :: replace sql 
Sql :: full-text index mysql 
Sql :: offset in postgresql example 
Sql :: greater than or equal to symbol in postgres 
Sql :: row number sql 
Sql :: sql length 
Sql :: mysql calcular idade 
Sql :: sql into 
Sql :: grab part of a string sql 
Sql :: query only first letter string 
Sql :: get last inserted primary key 
Sql :: Oracle SQL join three tables and group by column 
Sql :: SQL SMALLDATETIME Data Type 
Sql :: trigger sql server 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =