`

Foreign key of the table

阅读更多
I didn't care of the foreign key before, today I have find my problem with it.
The foreign key must be fllow some constraints.
For example, I have two tables, one named A and one named B. The B table has a column references of the column of A table, and this column in the A table must be a constraint of unique or primary.
Just my note.
分享到:
评论

相关推荐

    MySQL添加外键时报错:1215 Cannot add the foreign key constraint的解决方法

    这篇文章主要涉及到在数据创建表时,遇到ERROR 1215 (HY000): Cannot add foreign key constraint 问题方面的内容,对于在数据创建表时,遇到同样问题感兴趣的同学可以参考一下。 一、问题的提出 创建两个表:  ...

    SSD7 选择题。Multiple-Choice

    The foreign key in a table T1 _____ the same _____ as the corresponding primary key in table T2. must have, name need not have, name must have, domain (a) I, II, and III (b) I and II (c) ...

    OCP考试WORD文档(一小部分)

    The PROD_ID column is the foreign key in the SALES table, which references the PRODUCTS table. Similarly, the CUST_ID and TIME_ID columns are also foreign keys in the SALES table referencing the ...

    微软内部资料-SQL性能优化5

    The number of levels in an index will vary depending on the number of rows in the table and the size of the key column or columns for the index. If you create an index using a large key, fewer ...

    详细oracle笔记1

    alter table table_name add constraint fk_name foreign key (table_column) references key_table_name; 3.使主键或外键失效、生效 alter table table_name disable(enable) constraint key_name;

    MySql建表语句的外键约束分离工具(FOREIGN KEY)

    在MySql数据库建表时,如果CREATE TABLE语句中添加了FOREIGN KEY,那么所依赖的表必须先被创建,痛苦不堪,使用我这个工具可以将外键约束的语句分离出来,单独执行。 具体说明可以参考帖子 ...

    SSD7 EX1 答案

    3. For each table, identify the Foreign Key(s) (FKs) and the integrity constraints. Fully justify your answer. 2. List all columns of your tables, and the domains (the data types and formats) of ...

    bbs论坛项目运用SSH框架Oracle数据库编写的一个简单示列项目

    -- Create/Recreate primary, unique and foreign key constraints alter table USERS add constraint PK_USERID primary key (USERID) using index tablespace SYSTEM pctfree 10 initrans 2 maxtrans 255 ...

    ssd7 exercise3

    FOREIGN KEY (callnumber) REFERENCES TITLE4(callnumber), FOREIGN KEY (libid) REFERENCES MEMBER4(libid) ); CREATE TABLE PURCHASE_ORDER4 (ponum char(8) NOT NULL, qty int, orderdate date, duedate ...

    聊天室系统数据库设计.txt

    PRIM PRIMARY KEY, groupname varchar(20) not null, ) CREATE TABLE friendship ( userid int CONSTRAINT u_FORE FOREIGN KEY REFERENCES users(userid), friendid int CONSTRAINT f_FORE FOREIGN KEY REFERENCES ...

    微软内部资料-SQL性能优化3

    In our example, if one transaction (T1) holds an exclusive lock at the table level, and another transaction (T2) holds an exclusive lock at the row level, each of the transactions believe they have ...

    课程设计—仓库设备管理

    课程设计—仓库设备管理系统.doc 创建基本表的SQL代码: create table Equipment ( ...alter table Stock add constraint Eno3 foreign key(Eno) references Equipment(Eno) on update cascade on delete cascade

    JBPM建表语句

    -- Create/Recreate primary, unique and foreign key constraints alter table JBPM4_DEPLOYMENT add primary key (DBID_) using index tablespace CSSCIS pctfree 10 initrans 2 maxtrans 255 storage ...

    学生成绩管理系统源代码

    delete foreign key FK_CHOOSE_C_CHOOSE_CO_COURSES end if; if exists(select 1 from sys.sysforeignkey where role='FK_CHOOSE_C_CHOOSE_CO_STUDENT') then alter table choose_course delete foreign key FK_...

    python-mysql day05.txt

    2、alter table 表名 drop foreign key 外键名; 5、已有表 alter table 表名 add constraint 外键名 foreign key(字段) references 主表(字段) on delete ... on update ... 6、注意 在已有表中添加外键时,...

    数据库设计题.docx

    Create table 商品供给( 商品号 int, 供给者号 int, Primary key ( 商品号, 供给者号 ), Foreign key 商品号 references 商品 (商品号), Foreign key 供给者号 references 供给商 (供给者号)) Create table 学生( ...

    华南理工大学计算机全英班数据库实验

    4. The score of a course that a student chose can be queried based on a student’s Name (or ID) and a course’s Name (or ID). If no student’s and course’s ID or Name are given, show all scores of ...

    123456789112

    foreign key (sno) references student(sno), foreign key (cno) references course(cno) ); go insert into student values('2001','zhansan','男',18); insert into student values('2002','lisi','男',20); ...

    MIS学生信息管理系统

    alter table class add constraint fk_class_deptid foreign key (deptid)references department(id) //老师信息表 create table teacher ( id int (5)auto_increment primary key, tno varchar(5), tname varchar...

    java web项目单线程

    Alter table score add foreign key(列名) references 表名(列名) 设默认值:Alter table student alter sname set default '小丁'; 删除一列: Alter table student drop upass; 表名更改: Alter table student ...

Global site tag (gtag.js) - Google Analytics