在sql中,自动生成ID号?
我有一表customer中有一列CUSTOMER_ID已经定义为主键了,也定义了关系。现在我想当我插入一天记录时它能自动生成一个号(比前一个号多1)用触发器:部分代码--...
我有一表customer中有一列CUSTOMER_ID已经定义为主键了,也定义了关系。现在我想当我插入一天记录时它能自动生成一个号(比前一个号多1)用触发器:部分代码--后面怎么写?
CREATE TRIGGER [Z_liang_C] ON [dbo].[customer]
INSTEAD OF INSERT
AS
----? 展开
CREATE TRIGGER [Z_liang_C] ON [dbo].[customer]
INSTEAD OF INSERT
AS
----? 展开
展开全部
CREATE SEQUENCE customer_sequence
START WITH 10000
INCREMENT BY 1;
INCREMENT BY 1;
CREATE TABLE customer(
customer_id NUMBER(5) PRIMARY KEY,
first_name VARCHAR2(20),
last_name VARCHAR2(20),
major VARCHAR2(30),
current_credits NUMBER(3));
INSERT INTO students(customer_id,first_name,last_name,major,current_credits)
VALUES(student_sequence.NEXTVAL,'Scott','Smith','Computer Science',11);
START WITH 10000
INCREMENT BY 1;
INCREMENT BY 1;
CREATE TABLE customer(
customer_id NUMBER(5) PRIMARY KEY,
first_name VARCHAR2(20),
last_name VARCHAR2(20),
major VARCHAR2(30),
current_credits NUMBER(3));
INSERT INTO students(customer_id,first_name,last_name,major,current_credits)
VALUES(student_sequence.NEXTVAL,'Scott','Smith','Computer Science',11);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询