create table type
(
Type_ID int primary key NOT NULL AUTO_INCREMENT,
TypeName varchar(25) not null
)
ENGINE=INNODB AUTO_INCREMENT=1;我想把 Type_ID 列设为主键,并且是自动增长列,
从网上搜了一下,大概是这样,可运行出错,不知道是什么问题了
大家帮忙解决下啦
(
Type_ID int primary key NOT NULL AUTO_INCREMENT,
TypeName varchar(25) not null
)
ENGINE=INNODB AUTO_INCREMENT=1;我想把 Type_ID 列设为主键,并且是自动增长列,
从网上搜了一下,大概是这样,可运行出错,不知道是什么问题了
大家帮忙解决下啦
解决方案 »
- sql server 2005 没有安装全文索引但是现在要用了怎么办
- 不知还有没有办法进入SQL2005数据库,求助~~~~~~
- 在服務器上陞級MSSQL 2000到MSSQL 2005.但我用SQL2005打开管理台时,看到的核心还是2000的.(就是8.0版的)
- 关于Sql 条件拼接的一点疑问
- 如何 记录 操作sql server 客户 的 IP 地址 ????????????????????
- sql server 2000 optimizer lock hints 选项问题
- 新手问题
- 在线等,我写了一条SQL语句,我想通过for 循环把SQL语句中的每条记录插入到另一个表中?如何实现
- 在sql7中,一个库的属性-〉选项-〉设置-〉select into/bulk copy 在sql2000中哪里有?
- 导入的数据怎么找到它的table.100分,我是菜鸟,求教!
- 求教like表达式
- 人力资源系统E-R图
create table type
(
Type_ID int identity(1,1) primary key NOT NULL ,
TypeName varchar(25) not null
)
(
Type_ID int identity(1,1) primary key NOT NULL ,
TypeName varchar(25) NOT NULL
)
create table typedddd
(
Type_ID int(3) AUTO_INCREMENT NOT NULL primary key,
TypeName varchar(25)
)
create table type
(
Type_ID int identity(1,1) primary key NOT NULL ,
TypeName varchar(25) NOT NULL
)你只要输入TYPENAME的数据就行了
ID会自动增长
create table desttable
(
Type_ID int identity(1,1) primary key not null,
TypeName varchar(25)
)
identity 的语法是,第一个参数为自增量初始值,第2个参数是自增步长,如果想从10开始,每次增长2的话,那么identity的形式就要是identity(10,2)
insert into type values('0','AAAA')
insert into type values('0','BBBB')
Type_ID TypeName
1 AAAA
2 BBBB
ALTER TABLE type AUTO_INCREMENT = 1ENGINE=INNODB AUTO_INCREMENT=1;这两句话什么意思呀?
恩,fwacky 你是怎么这么快知道 insert into type values('0','AAAA') 这么写的?
楼主说的是MYSQL,不是MSSQL。
大家快帮帮我啦 ^_^
ALTER TABLE type AUTO_INCREMENT = 3这是,修改它的初始值
create table product
(
Pro_ID int AUTO_INCREMENT primary key,
Pro_Name varchar(25) not null,
Pro_TypeID int not null,
Pro_Sample varchar(100) not null,
Pro_price DECIMAL not null,
Pro_curt varchar(300) not null,
Pro_Time datetime not null
)
ALTER TABLE product ADD CONSTRAINT fk_Pro_TypeID FOREIGN KEY (Pro_TypeID) REFERENCES type(Type_ID) ON UPDATE CASCADE ;
我想一快运行,可就是不行,没次都要先键完表,在添加约束在 mssql 里 加个 go 就可以了,这个怎么弄呀?
create table product
(
Pro_ID int AUTO_INCREMENT primary key,
Pro_Name varchar(25) not null,
Pro_TypeID int not null,
Pro_Sample varchar(100) not null,
Pro_price DECIMAL not null,
Pro_curt varchar(300) not null,
Pro_Time datetime not null
) ;ALTER TABLE product ADD CONSTRAINT fk_Pro_TypeID FOREIGN KEY (Pro_TypeID) REFERENCES type(Type_ID) ON UPDATE CASCADE ;
(
Pro_ID int AUTO_INCREMENT primary key,
Pro_Name varchar(25) not null,
Pro_TypeID int not null,
Pro_Sample varchar(100) not null,
Pro_price DECIMAL not null,
Pro_curt varchar(300) not null,
Pro_Time datetime not null
) ;ALTER TABLE product ADD CONSTRAINT fk_Pro_TypeID FOREIGN KEY (Pro_TypeID) REFERENCES type(Type_ID) ON UPDATE CASCADE ;
如果我那需要一个注释,而且还想批量运行怎么弄?
create table product
(
Pro_ID int AUTO_INCREMENT primary key,
Pro_Name varchar(25) not null,
Pro_TypeID int not null,
Pro_Sample varchar(100) not null,
Pro_price DECIMAL not null,
Pro_curt varchar(300) not null,
Pro_Time datetime not null
) ;/**dddddddddddddddddddddddddd*/ALTER TABLE product ADD CONSTRAINT fk_Pro_TypeID FOREIGN KEY (Pro_TypeID) REFERENCES type(Type_ID) ON UPDATE CASCADE ;
create table product
(
Pro_ID int AUTO_INCREMENT primary key,
Pro_Name varchar(25) not null,
Pro_TypeID int not null,
Pro_Sample varchar(100) not null,
Pro_price DECIMAL not null,
Pro_curt varchar(300) not null,
Pro_Time datetime not null
) ;# dddddddddddddddddddddALTER TABLE product ADD CONSTRAINT fk_Pro_TypeID FOREIGN KEY (Pro_TypeID) REFERENCES type(Type_ID) ON UPDATE CASCADE ;
=====================================================
这个我就不会了!
我学的是,Visual C# .net
找不到 java 连 mysql 的 mysql连接驱动呀!
(
col1 int not null auto_increment,
primary key(col1),
col2 varchar(2)
);
做练习啦,给自己考试,因为mysql我不会,所以考试加学习咯
(
col1 int not null auto_increment,
primary key(col1),
col2 varchar(2)
);
(
Type_ID int AUTO_INCREMENT primary key,
TypeName varchar(25) not null
)
IDENTITY 这个是SQLSERVER中设置自动增长列的函数
(
Type_ID int AUTO_INCREMENT primary key,
TypeName varchar(25) not null
) 如果是主键的话不用设置not null
MYSQL中的自动增长默认是从1开始的