create database db_test;
--创建数据库的时候指定其所有者为postgres,并且指定其编码格式为utf-8
create database db_test1 with owner =postgres encoding='utf-8'
--修改数据库的名称
alter database db_test1 rename to db_test3
--删除数据库
drop database db_test3
- Smallint 小范围整数,取值范围:-32768—32767
- Int(integer) 普通大小整数 -2147483648-2147483647
- Real 6位十进制数字精度
- Numberic(m,n) 任意精度类型
使用numberic会产生四舍五入的,
例如number(4,2)
100.23没问题、1000.23就会报错,超出精度、100.235不会报错,但是存在数据库中就变成了100.24;





1是否在1和2之间,3是否在1和2之间

2是否在1和2组成的集合之中、2是否在3和4组成的集合之中,2是否不在3和4组成的集合之中;

在数据库中1和y表示真,0和n表示为假;












create or replace function add(int,int,int) returns int
as ’ select $1 + $2 + $3; ’
language sql
returns null on null input;
Create or replace 就是在创建函数的过程中,看是否已经存在了这个函数,如果存在,就更新这个函数,
–删除函数
drop function add(int,int,int)

创建与删除索引(默认为B-tree索引)


Insert 批量插入:

将student表里面的数据全部插入进student_new表中

清空一张表


Null值查询,要用is null 或者is not null

将null值放在最后。

显示数据,煤业显示5条,


Unio all会产生产生重复数据,union就会把重复数据去点

未完待续…