create table users (
id serial primary key, -- id 自动递增
name character varying, -- 指定字符串输出长度大小
preferences jsonb, -- 字段类型为JSON非常适合存储非结构化的数据
created_at timestamp without time zone -- 始终以UTC格式存储时间
);
create table users (
id serial primary key,
name character varying not null,
active boolean default true
);
alter table events rename to events_backup;
truncate my_table restart identity;
create table dupe_users as (select * from users);
-- 这个 'with no data' 意思是只有结构,没有实际的行
create table dupe_users as (select * from users) with no data;
alter table users add column created_at timestamp without time zone;
alter table users add column bio string character varying not null;
alter table users add column active boolean default true;