PostgreSQL-constraint
CREATE TABLE语法
CREATE [[ GLOBAL | LOCAL ]{ TEMPORARY | TEMP }] TABLE table_name
(
{ column_name data_type [ DEFAULT default_expr ][ column_constraint [...]]
| table_constraint
| LIKE parent_table [{ INCLUDING | EXCLUDING } DEFAULTS ]
}[,...]
)
[ INHERITS ( parent_table [,...])]
[ WITH OIDS | WITHOUT OIDS ]
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP }]
[ TABLESPACE tablespace ]
紧跟在字段定义后 column_constraint |
和字段定义并列写在表定义中(约束子句) table_constraint |
|
|
[CONSTRAINT constraint_name] |
[CONSTRAINT constraint_name] |
表约 |
检查 |
NOT NULL | NULL |
|
字段 |
非空 |
[CONSTRAINT constraint_name] |
[CONSTRAINT constraint_name] |
表约 |
非空 |
UNIQUE |
[CONSTRAINT constraint_name] |
表索 |
唯一 |
[CONSTRAINT constraint_name] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] |
[CONSTRAINT constraint_name] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] |
表外 |
外键 |
ADD [ COLUMN ] |
ADD table_constraint |
相关 |
非空约束not null有两种方式实现,一种是修饰词“非空”,如
creata table a(a int not null);
alter table a alter a drop not null; 一种是check,而check又分为字段约束和表约束,如
create table a(a int check(a is not null));
alter table a drop constraint a_a_check; 默认值default 也是通过alter语句的set和drop来进行修改的。 唯一约束unique 可以通过DROP CONSTRAINT 约束名称来删除。 在使用alter table 语句添加新字段的时候只能使用column_constraint,只有单纯添加约束才能使用table_constraint,两种情况下unique约束就存在区别。
PostgreSQL-constraint的更多相关文章
- PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库
最近准备下PostgreSQL数据库开发的相关知识,本文把总结的PPT内容通过博客记录分享,本随笔的主要内容是介绍PostgreSQL数据库的基础信息,以及如何在我们的开发框架中使用PostgreSQ ...
- PostgreSQL数据库中的常见错误
转载以作参考. 错误1 FATAL: connection limit exceeded for non-superusers 原因:非超级用户的连接数(max_connections - super ...
- 转载:postgresql分区与优化
--对于分区表constraint_exclusion 这个参数需要配置为partition或on postgres=# show constraint_exclusion ; constraint_ ...
- PostgreSQL function examples
warehouse_db=# CREATE TABLE warehouse_tbl(warehouse_id INTEGER NOT NULL,warehouse_name TEXT NOT NULL ...
- postgresql常用命令
1.createdb 数据库名称 产生数据库2.dropdb 数据库名称 删除数据库 3.CREATE USER 用户名称 创建用户4.drop User 用户名称 删除用户 5.SELECT use ...
- 【转载】Fast Inserts to PostgreSQL with JDBC and COPY FROM
source: http://rostislav-matl.blogspot.com/2011/08/fast-inserts-to-postgresql-with-jdbc.html Thanks ...
- Fluent NHibernate and Mysql,SQLite,PostgreSQL
http://codeofrob.com/entries/sqlite-csharp-and-nhibernate.html https://code.google.com/archive/p/csh ...
- PostgreSQL Partitions
why we need partitions The first and most demanding reason to use partitions in a database is to inc ...
- PostgreSQL index types and index bloating
warehouse_db=# create table item (item_id integer not null,item_name text,item_price numeric,item_da ...
- PostgreSQL数据库中跨库访问解决方案
PostgreSQL跨库访问有3种方法:Schema,dblink,postgres_fdw. 方法A:在PG上建立不同SCHEMA,将数据和存储过程分别放到不同的schema上,经过权限管理后进行访 ...
随机推荐
- 无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Word._Application”。
无法将类型为“Microsoft.Office.Interop.Word.ApplicationClass”的 COM 对象强制转换为接口类型“Microsoft.Office.Interop.Wor ...
- 基于 Hive 的文件格式:RCFile 简介及其应用
转载自:https://my.oschina.net/leejun2005/blog/280896 Hadoop 作为MR 的开源实现,一直以动态运行解析文件格式并获得比MPP数据库快上几倍的装载速度 ...
- HTML特殊符号汇总
较常用的飘黄处理了 ´ ´ © © > > µ µ ® ® & & ° ° ¡ ¡ » » ¦ ¦ ÷ ÷ ¿ ¿ ¬ ¬ § § • • ½ ½ « « ¶ ¶ ¨ ...
- form表单提交数据
js代码: // form 跳转 gotourl//跳转的页面 options json格式参数 function FromGoTo(gotourl, options) { var inputhtml ...
- REST服务介绍
body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; } RESTful service是一种架构模式,近几年比 ...
- 26、ASP.NET MVC入门到精通——后台管理区域及分离、Js压缩、css、jquery扩展
本系列目录:ASP.NET MVC4入门到精通系列目录汇总 有好一段时间没更新博文了,最近在忙两件事:1.看书,学习中...2.为公司年会节目做准备,由于许久没有练习双截棍了,难免生疏,所以现在临时抱 ...
- Logging configuration
The Play logger is built on Log4j. Since most Java libraries use Log4j or a wrapper able to use Log4 ...
- centos虚拟机复制移动后网络配置无效
移植Centos虚拟机后无法联网解决1.迁移以后,会存在其中一个网卡无法启动(eth0 or eth1) [root@ ~]# ifup eth0 WARNING: Deprecated config ...
- jeecg环境搭建20160707
1.首页修改位置:src/main/webapp/webpage/main 2.tomcat45秒超时启动修改,open打开servers项目,在右上角处的timeouts参数修改: 3.eclips ...
- Android开发学习——Android项目的目录结构
Android项目的目录结构: 资源文件夹: 清单配置文件: Android的四大组件在使用前全部需要在清单文件中配置 <?xml version="1.0" encodin ...