我们可以在创建表时应用主键和标识 [英] can we apply primary key and identity when creating a table
本文介绍了我们可以在创建表时应用主键和标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友..
我的要求是我想在创建表格时将主键和标识应用于列
这是我的语法
create table emp(eno int主键标识(1,1),ename varchar(20))
解决方案
请将查询更改为以下格式
对于Ms-Sql
create table \\ temp(eno int 不 null identity ( 1 , 1 )约束 pk_eno primary key ,ename varchar ( 20 ))
For My-Sql
CREATE TABLE \\ temp(
eno INT NOT NULL AUTO_INCREMENT,
ename VARCHAR ( 20 ),
PRIMARY KEY (eno)
)
希望它有所帮助。
hi friends ..
my requirement is i want to apply the primary key and identity to a column, when creating a table
here is my syntax
create table emp (eno int primary key identity(1,1) ,ename varchar(20))
解决方案
Please change the query to the following format
For Ms-Sql
create table emp (eno int not null identity(1,1) constraint pk_eno primary key,ename varchar(20))
For My-Sql
CREATE TABLE emp ( eno INT NOT NULL AUTO_INCREMENT, ename VARCHAR(20), PRIMARY KEY (eno) )
Hope it helps.
这篇关于我们可以在创建表时应用主键和标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文