I am trying create a table with auto increment in Oracle SQL. I have the following SQL code:
DROP TABLE "Account" CASCADE CONSTRAINTS;
CREATE TABLE "Account" (
"Id" NUMBER(5) NOT NULL,
"Name" VARCHAR2(32) NOT NULL,
"User" VARCHAR2(16) NOT NULL,
"Email" VARCHAR2(32) NOT NULL,
"Password" VARCHAR2(16) NOT NULL,
"Level" VARCHAR2(16) NOT NULL,
CONSTRAINT "Account_pk" PRIMARY KEY ("Id")
);
DROP SEQUENCE "Account_seq";
CREATE SEQUENCE "Account_seq" START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 10000;
INSERT INTO "Account" VALUES (Account_seq.NEXTVAL, 'xxx', 'xxx', 'xxx', 'xxx', 'user');
INSERT INTO "Account" VALUES (Account_seq.NEXTVAL, 'xxx', 'xxx', 'xxx', 'xxx', 'user');
Oracle SQL Developer says that Account_seq is created, but still it gives me an error: "sequence does not exist"...
insert
statements with explicit column names too, so you can tell which value maps to which column. – Marc