[英]Oracle Query: How to create unique key on inserting record?
Here I have few records.这里我的记录很少。
Id is primary key and auto increment. Id 是主键和自动增量。
Name is Varchar2名称是 Varchar2
Result is Char结果是字符
Registration Number is unique key and it is combination of Name-Id.注册号是唯一键,它是名称-ID 的组合。 How can I make my registration number insert in default like this?如何让我的注册号像这样默认插入?
My table looks like:我的桌子看起来像:
id. Name. Result. Registration Number
___________________________________________
1. John P. John-1
2. Tom. P. Tom-2
3. John. P. John-3
4. Jerry. F. Jerry-4
try this尝试这个
CREATE TABLE t1
(
id NUMBER NOT NULL,
FirstName VARCHAR2(20),
LastName VARCHAR2(20),
FullName VARCHAR2(100) GENERATED ALWAYS AS (FirstName || ' ' || LastName || '' || id) VIRTUAL,
PRIMARY KEY (id)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.