在错误中创建表 [英] Create table in Error

查看:55
本文介绍了在错误中创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建表empDetails(
EMP_ID int(11)主键NOT NULL,
密码varchar(10)NOT NULL
);


忽略表与下表的关系.


创建表LEAVE_DETAILS_ADMIN(
EMP_ID int NOT NULL外键,
LeaveEarnedCredit float(2),
LeaveCasualCredit float(2),
LeaveMaternityCredit float(2)
);

我收到了此错误第二张表

CREATE TABLE empDetails (
EMP_ID int(11) primary key NOT NULL,
password varchar(10) NOT NULL
);


obove table relation to below table.


CREATE TABLE LEAVE_DETAILS_ADMIN (
EMP_ID int NOT NULL foreign key ,
leaveEarnedCredit float(2),
leaveCasualCredit float(2),
leaveMaternityCredit float(2)
);

I got this Error Second Table

推荐答案

检查此链接

http://www.w3schools.com/sql/sql_foreignkey.asp [ http://www.1keydata.com/sql/sql-foreign-key.html [ ^ ]

他们会帮助您

此链接也将指导您

Check this link

http://www.w3schools.com/sql/sql_foreignkey.asp[^]

http://www.1keydata.com/sql/sql-foreign-key.html[^]

They will help you

This link too will guide you

http://blog.sqlauthority.com/2008/09/08/sql-server-%E2%80%93-2008-creating-primary-key-foreign-key-and-default-constraint/[^]


您需要告诉SQL外键引用哪个表:
You need to tell SQL which table the foreign key refers to:
EMP_ID int NOT NULL foreign key REFERENCES empDetails,


顺便说一句,将两个密钥声明为相同大小是个好主意-如果您显式地声明int(11)为一个密钥,则还应该使用int(11)作为外键,而不仅仅是int


BTW, the would be a good idea to declare both keys to be the same size - if you explicitly state int(11) for one, your should also use int(11) for the foreign key rather than just int


首先INT(11)无效,您不能在数据类型INT上指定列长.
创建表empDetails(
EMP_ID int主键NOT NULL,
密码varchar(10)NOT NULL
);


创建表LEAVE_DETAILS_ADMIN(
EMP_ID int NOT NULL外键引用empDetails(EMP_ID),
LeaveEarnedCredit float(2),
LeaveCasualCredit float(2),
LeaveMaternityCredit float(2)
);


试试这个,Hop会很好用的.....

最好的:-)
First of all INT(11) is INVALID, You can''t specify the column length on the data type INT..

CREATE TABLE empDetails (
EMP_ID int primary key NOT NULL,
password varchar(10) NOT NULL
);


CREATE TABLE LEAVE_DETAILS_ADMIN (
EMP_ID int NOT NULL foreign key references empDetails(EMP_ID) ,
leaveEarnedCredit float(2),
leaveCasualCredit float(2),
leaveMaternityCredit float(2)
);


try this, Hop will works fine,....

All the Best:-)


这篇关于在错误中创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆