(1)时间类型比较,需要添加关键字     timestamp

select * from track where create_time > timestamp '2021-08-17 11:41:09';

 (2)主键自增    

    A. 建表时采用   SERIAL 关键字

create table tes_user
(
id SERIAL primary key,
user_name varchar(10) null,
user_age int null
);

insert into tes_user(user_name,user_age) values('张三',19),('李四',20);

 

     查看数据库是成功插入数据的,并且主键id自增。

     B. 如果表已经存在(同样是tes_user表),修改表的字段使其自增

  •  创建一个和自增关联的序列   SEQUENCE
create SEQUENCE tes_user_id_seq START 1;
  •  将创建的序列添加到默认值位置 nextval('tes_user_id_seq'::regclass) ,保存即可。

insert into tes_user(user_name,user_age) values('王五',20),('十一',20);

 

posted on 2021-08-17 17:00  CccccDi  阅读(159)  评论(0编辑  收藏  举报