postgresql 基本查询

建表语句

-- ======== sys_dict_type
create table sys_dict_type(
id bigint primary key,
name varchar(100),
type varchar(100),
group_code  varchar(100),
status char(1)
);

comment on table sys_dict_type is '系统字典类型表';
comment on column sys_dict_type.name is '字典名称';
comment on column sys_dict_type.type is '字典类型编码';
comment on column sys_dict_type.group_code is '字典分组 (system:系统字典)';
comment on column sys_dict_type.status is '状态 (0:正常 1:停用)';


create sequence seq_sys_dict_type increment 1 minvalue 1 maxvalue 9223372036854775807 start with 1 cache 1 owned by sys_dict_type.id;

alter table sys_dict_type alter column id set default nextval('seq_sys_dict_type');

insert into sys_dict_type(name,type,group_code,status) values('性别','gender','system','0');
insert into sys_dict_type(name,type,group_code,status) values('模块','module','system','0');
insert into sys_dict_type(name,type,group_code,status) values('left','left','left','0');


-- ======== sys_dict_type
create table sys_dict_type
create table sys_dict_data(
id bigint primary key,
type varchar(100),
group_code  varchar(100),
label  varchar(100),
value  varchar(100),
default_value char(1),
status char(1)
);

comment on table sys_dict_data is '系统字典值表';
comment on column sys_dict_data.type is '字典类型编码';
comment on column sys_dict_data.group_code is '字典分组 (system:系统字典)';
comment on column sys_dict_data.label is '字典标签';
comment on column sys_dict_data.value is '字典键值';
comment on column sys_dict_data.default_value is '是否默认值 (Y:是 N:否)';
comment on column sys_dict_data.status is '状态 (0:正常 1:停用)';




create sequence seq_sys_dict_data increment 1 minvalue 1 maxvalue 9223372036854775807 start with 1 cache 1 owned by sys_dict_data.id;

alter table sys_dict_data alter column id set default nextval('seq_sys_dict_data');

insert into sys_dict_data(type,group_code,label,value,default_value,status) values('gender','system','男','male','Y','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('gender','system','女','female','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','system','系统','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','auth','授权与认证','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','order','订单','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','product','商品','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','member','会员','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','pay','支付','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','stock','库存','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','cart','购物车','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','cms','内容管理','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','report','报表','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','promotion','促销','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','seller','商家','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('module','system','search','搜索','N','0');
insert into sys_dict_data(type,group_code,label,value,default_value,status) values('right','right','right','right','N','0');

select * from sys_dict_data;

分页查询

SELECT * FROM table_name
LIMIT [pageSize] OFFSET [pageNum]
-- pageSize:每页显示条数
-- pageNum:从第几条开始查询 
select * from sys_dict_data limit 3 offset 0; -- 第一页
select * from sys_dict_data limit 3 offset 1; -- 第二页
posted @ 2024-06-09 10:40  潼关路边的一只野鬼  阅读(9)  评论(0编辑  收藏  举报