postgresql学习

Q: Docker 安装postgress账户时效过期 

 

 

--------------------------------------------------------------------------

1、每个数据库厂商的集成的接口定义

 

 

 

 

 

 

 

 

 2. 创建数据库,可以通过pgadmin创建,也可通过脚本创建

 

 

 2-1、创建表,表的相关操作

 

 

 

create table student(
   id int,
   name varchar(30),
   score numeric(5,2),
   birthday date
)

 

 

3、数据类型介绍 (数值、日期、字符串)

3-1、数值类型

 

 

PS: numeric(5,2) 表示不包含小数点的浮点类型,5是长度,2是精度,会四舍五入
create table temp(
   x smallint,
   y int,
   z real,
   n numeric(5,2) 
)

insert into temp values(12,10,11.01,111.23);
insert into temp values(12,10,11.01,111.223);
insert into temp values(12,10,11.01,111.229);

select * from temp

 

 

 

 

 

 

 

create table temp1(
   ch char(10),
   vch varchar(30),
   t text
);

insert into temp1 values('我爱你11','我爱你11','我爱你11');
insert into temp1 values('我爱你1111111','我爱你11','我爱你11');
insert into temp1 values('22我爱你1111111','我爱你11','我爱你11'); 超过报错


select concat('(',ch,')'),concat('(',vch,')'),concat('(',t,')') from temp1

 

 

 

 4、运算符

 

 

 

 

PS : 字符串会自动转换为数值对比

 

 

PS: between and是闭合 >=  ,<=

 

 

PS:  _是匹配一个字符

 

 

PS: 逻辑运算符, 1和y都是真 ,0喝n都是假的

 

 

 

 

 

 

 

 

 

select current_date,current_time,now();

 

 

 

 

PS: 自定义concat_test函数

 

 

 

 

PS: 

B-tree是使用最频繁的索引;

Hash索引在实际使用中是比较少的;

Gist: 这种索引就是用来拓展使用的

 

 

 

 

PS: 视图就是把复杂业务封装起来,使用的时候再直接查询

 

 

 

 

 

 

 

 

posted on 2021-10-16 20:54  biyangqiang  阅读(76)  评论(0)    收藏  举报

导航