惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
Vercel News
Vercel News
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
T
Threatpost
Security Latest
Security Latest
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
I
Intezer
P
Privacy International News Feed
D
Docker
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
A
Arctic Wolf
IT之家
IT之家
S
SegmentFault 最新的问题
S
Securelist
博客园 - 叶小钗
N
News and Events Feed by Topic
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - Franky
GbyAI
GbyAI
AI
AI
Y
Y Combinator Blog
WordPress大学
WordPress大学
Latest news
Latest news
Microsoft Security Blog
Microsoft Security Blog
人人都是产品经理
人人都是产品经理
N
News | PayPal Newsroom
The Cloudflare Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
I
InfoQ

博客园 - Augur

又开始使用,学习 Integer和int Mybatis的学习1 初次安装与错误排除 知乎的 Java开发中的23种设计模式(转) vo与po entityVo对象与entity对象 dao 网上Java总结 dto vo html css col-md-offset VUE - 相对路径 转:防止跨站攻击,安全过滤 Java中的包装数据类型 一些名词 mysql 表结构 楚乔传 Princess Agents Java学习08 (第一遍) - SpringMVC
数据表 键值定义
Augur · 2017-07-26 · via 博客园 - Augur

PK - Primary Key

IX - Non-Unique Index

AK - Unique Index (AX should have been AK (Alternate Key))

CK - Check Constraint

DF - Default Constraint

FK - Foreign Key

UQ - Unique Constraint

SQL中PK,FK意思:
--主键
constraint PK_字段 primary key(字段),

--唯一约束
constraint UK_字段 unique key(字段),

--默认约束
constrint DF_字段 default('默认值') for 字段,

--检查约束
constraint CK_字段 check(约束。如:len(字段)>1),

--主外键关系
constraint FK_主表_从表 foreign(外键字段) references 主表(主表主键字段)

替代键的解释(alternate key)

SQL技巧:唯一性约束

    所谓唯一性约束(unique constraint)不过是数据表内替代键的另一个名称而已。替代键(alternate key)可以是数据表内不作为主键的其他任何列,只要该键对该数据表唯一即可。换句话说,在唯一列内不允许出现数据重复的现象。比方说,你可以用车辆识别代号(VIN)作为汽车(Automobile)数据表的替代键,在汽车数据表里,主键是汽车识别号(Automobile Identification),这是一种由系统自动生成的ID。你可以在汽车表内对VIN施加唯一性约束,同时再创建一个需要VIN的表。在这个新表内可以声明外键指向汽车表。这样,只要汽车表内有VIN输入数据库就会检验VIN输入结果。这就是保证数据库内数据完整性的另一种有效的措施。

    以下是演示唯一性约束作为外键引用点的示例代码:

    create table parent
    (parent_id int not null,      -- Primary key
    parent_alternate_key int not null,     -- Alternate key
    parent_col1 int null,
    parent_col2 int null,
      constraint pk_parent_id primary key (parent_id),
      constraint ak_parent_alternate_key unique_
       (parent_id, parent_alternate_key)
    )
    go
    insert parent values ( 1, 10, 150, 151)
    insert parent values ( 2, 11, 122, 271)
    insert parent values ( 3, 12, 192, 513)
    insert parent values ( 4, 13, 112, 892)
    go
    create table child2
    (child2_parent_id int not null,     -- Primary key/Foreign key
    child2_id int not null,     -- Primary key
    child2_col1 int null,
    child2_parent_alternate_key int not null,  -- Foreign key
        constraint pk_child2 primary key (child2_parent_id, child2_id),
        constraint fk_child2_parent foreign key (child2_parent_id) 
    references dbo.parent(parent_id),
        constraint fk_pk_ak_child2_parent foreign key _
      (child2_parent_id, child2_parent_alternate_key) _
      references dbo.parent(parent_id, parent_alternate_key)
    )
    go
    insert child2 values (1,1,34,10)
    insert child2 values (4,2,34,13)
    insert child2 values (2,3,34,11)
    go
    insert child2 values (1,4,34,23)   -- This one will fail
    go