1、创建表

CREATE table tb_user
(
    id serial primary key not null ,
    name varchar(20) not null default '' 
) ;


comment on column tb_user.id is '主键id';

comment on column tb_user.name is '用户名';

comment on table tb_user is '用户表';

-- 设置主键自增  serial

-- 设置表的备注信息

comment on table 表名 is '表注释';
comment on table tb_user is '用户表';

-- 设置列名备注

comment on column 表名.字段名 is '字段注释';
comment on column tb_user.name is '用户名';

-- 修改表名

alter table 原表名 rename to 新表名;
-- 关键字目前测试是不能当表名 alter table tb_user rename to user1;

-- 修改列名

alter table 表名 rename 字段名 to 新字段名
-- 还没经过测试

 -- 设置索引

create index 索引名称 on 表名 (列名);
create index idx_create_user on leave (create_user);

 

相关文章:

  • 2021-07-06
  • 2022-01-14
  • 2021-10-12
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2021-11-24
猜你喜欢
  • 2021-12-25
  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
相关资源
相似解决方案