postgresql数据库中的建表和约束

CREATE TABLE pdw_sample_receive_item_t (
  id varchar(50),
  sample_code varchar(30) constraint pk_pdw_sample_receive_item_t
            primary key,
  id_card varchar(255),
  run_time timestamp,
  sample_num varchar(255),
  sample_type varchar(255),
  state varchar(255),
  state_name varchar(255),
  dy_nums integer,
  is_contrast char(1),
  CONSTRAINT unique_pdw_sample_receive_item_t_id UNIQUE (id)
);
comment on table pdw_sample_receive_item_t is '数据仓库层_病历基本信息';

comment on column pdw_sample_receive_item_t.id_card  is '病例卡号';

CREATE INDEX idx_pdw_sample_receive_item_t_id_card ON pdw_sample_receive_item_t USING BTREE (id_card );

以上是postgresql数据中的建表的简单示例,其中主键:

sample_code varchar(30) constraint pk_pdw_sample_receive_item_t
            primary key

唯一键:

 CONSTRAINT unique_pdw_sample_receive_item_t_id UNIQUE (id)

索引创建:

CREATE INDEX idx_pdw_sample_receive_item_t_id_card ON pdw_sample_receive_item_t USING BTREE (id_card );

表注释:

comment on table pdw_sample_receive_item_t is '数据仓库层_病历基本信息';

字段注释:

comment on column pdw_sample_receive_item_t.id_card  is '病例卡号';

另外注意postgresql数据库中大小写是敏感的;

相关推荐

  1. postgresql数据库约束

    2023-12-12 15:40:02       64 阅读
  2. 数据库-约束

    2023-12-12 15:40:02       21 阅读
  3. 数据库约束

    2023-12-12 15:40:02       41 阅读
  4. MySQL 约束

    2023-12-12 15:40:02       42 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-12 15:40:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-12 15:40:02       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-12 15:40:02       82 阅读
  4. Python语言-面向对象

    2023-12-12 15:40:02       91 阅读

热门阅读

  1. GSIL:GitHub敏感信息泄露监控工具使用

    2023-12-12 15:40:02       65 阅读
  2. 找到字符串中所有字母异位词(LeetCode 438)

    2023-12-12 15:40:02       52 阅读
  3. 树莓派5安装opencv

    2023-12-12 15:40:02       64 阅读
  4. K12484 银行排队(bank)

    2023-12-12 15:40:02       61 阅读
  5. 飞行控制系统软件设计

    2023-12-12 15:40:02       57 阅读
  6. 一篇文章让你读懂Jenkins的用途

    2023-12-12 15:40:02       53 阅读
  7. 【后端】系统设计类题目汇总五

    2023-12-12 15:40:02       53 阅读