![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
postgresql
North北
这个作者很懒,什么都没留下…
展开
-
postgresql_python编程
1.前提:依赖sycopg2模块(PostgreSQL数据库适配器,小巧、快速、稳定);linux安装:#安装yum install python-psycopg2windows安装:#升级pippip install -U pip#安装psycopg2pip install psycopg2失败的情况,下载安装包,地址:https://github.co...原创 2018-11-06 10:28:10 · 6459 阅读 · 0 评论 -
postgresql_常用函数
coalesce(null,null,cd)返回参数列表中,第一个非空值。nvlnvl(a, b) a为null,返回b,否则返回a;nvl2nvl2(a, b, c) a为null,返回c,否则返回b;countSELECT count(*),返回记录的条数。distinctselect distinct on(字段) * from *; 相同值只返回...原创 2018-11-06 16:42:46 · 6161 阅读 · 0 评论 -
postgresql_基本语法
1.创建数据库:CREATE DATABASE "db001" WITH ENCODING='UTF8' CONNECTION LIMIT=100 TABLESPACE=pg_default;2.创建数据表:create table "db001.table001"(id numeric(12) PRIMARY KEY, phone numeric(12) UNIQUE NOT NUL...原创 2018-11-05 15:50:03 · 2153 阅读 · 0 评论 -
postgresql_环境配置
1.设置开机启动:#systemctl enable postgresql-9.6.service2.修改postgres密码&&重启服务:#Alter user postgres with password '123456';/usr/pgsql-9.6/bin/pg_ctl restart7.防火墙处理:systemctl stop firewalld ...原创 2018-11-05 15:31:56 · 2210 阅读 · 0 评论 -
postgresql_数据结构
1.postgresql层次:column(字段) ∈ table(表) ∈ schema(模式,架构) ∈ db(数据库) ∈ postgresql(服务)。2.shema,表的集合(容器,命名空间):#创建CREATE SCHEMA schema_name;3.字段类型:时间: date(日期),time(时间),timestamp (日期和时间)数字: num...原创 2018-11-05 16:41:39 · 1516 阅读 · 0 评论 -
postgresql_索引
1.简介:索引是用于加速从数据库检索数据的特殊查找表。索引为出现在索引列中的每个值创建一个条目。2.特点:索引使用SELECT查询和WHERE子句加速数据输出,但是会减慢使用INSERT和UPDATE语句输入的数据。3.创建:CREATE INDEX index_name ON table_name;单列索引,CREATE INDEX index_name ON tab...原创 2018-11-05 22:48:56 · 462 阅读 · 0 评论 -
postgresql_触发函数,序列
1.自动插入序号:创建自然数序列: CREATE SEQUENCE schema名.seq名 INCREMENT 2 START 1 MINVALUE 1 MAXVALUE 99999999 CACHE 1; ...原创 2018-11-05 23:59:42 · 1060 阅读 · 0 评论