暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

数据库表中的键

原创 えっと、ふふ 2023-09-10
146

CREATE table student( s_id integer, s_name varchar(100), gender char(2), PIN CHAR(18), UNIQUE (PIN) );#’指定一个候选键’

CREATE table student_BAK20230910( s_id integer, s_name varchar(100), gender char(2), PIN CHAR(18), UNIQUE (PIN,S_ID) );#’指定多个组合候选键’

CREATE table student_score( s_id int, c_id int, score int, primary key(c_id) );#指定主键

CREATE table student_score( s_id int , primary key, c_id int, score int);#指定主键

CREATE table student_score_bak20230910( s_id int, c_id int, score int, primary key(c_id,s_id) );#指定组合主键

CREATE table student_score2( s_id int , c_id int, score int, primary key(c_id), foreign key(s_id) references student(s_id) );#指定外键主键 #被关联表的字段必须是主键才行

alter table student add constraint primary key(s_id); #增加主键

alter table student drop constraint primary key(s_id); #删除主键

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论