06 2022 档案

摘要:with的使用 可以看出来with相当于一个临时表,如下示例表明with语句ename_emp将emp的empno,ename两个字段作为一个临时表进行使用 mydb=# with ename_tmp as (select empno,ename from emp) mydb-# select * 阅读全文
posted @ 2022-06-27 16:01 南大仙 阅读(134) 评论(0) 推荐(0) 编辑
摘要:交叉连接即即笛卡尔积 准备数据 CREATE TABLE EMP ( EMPNO int PRIMARY KEY, ENAME VARCHAR(10), JOB VARCHAR(9), MGR int, HIREDATE DATE, SAL int, COMM int, DEPTNO int ) i 阅读全文
posted @ 2022-06-27 16:00 南大仙 阅读(212) 评论(0) 推荐(0) 编辑
摘要:测试环境为CentOS Linux release 7.9,oracle11g,pg10 1.安装oracle客户端 https://www.oracle.com/database/technologies/instant-client.html 根据系统选择对应版本 分别下载如下安装包 使用rpm 阅读全文
posted @ 2022-06-23 16:41 南大仙 阅读(687) 评论(0) 推荐(0) 编辑
摘要:listener.ora LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) #记录了监听器LISTENER服务的全局数据库名、数据库路径和数据库实例名 SID_LIST_LI 阅读全文
posted @ 2022-06-23 10:52 南大仙 阅读(1402) 评论(0) 推荐(0) 编辑
摘要:weather表的外键为cities的主键city字段,如下为表结构 mydb=# \d weather Table "public.weather" Column | Type | Collation | Nullable | Default + + + + city | character va 阅读全文
posted @ 2022-06-23 09:52 南大仙 阅读(481) 评论(0) 推荐(0) 编辑
摘要:表分区 声明式划分 CREATE TABLE measurement ( city_id int not null,//城市id logdate date not null,//日期 peaktemp int,//峰值温度 unitsales int//销量 ); CREATE TABLE meas 阅读全文
posted @ 2022-06-22 17:39 南大仙 阅读(162) 评论(0) 推荐(0) 编辑
摘要:pg中的schema类似于mysql数据库的角色 实例-->database-->schema-->数据库对象,表,视图,存储过程,函数等 CREATE SCHEMA myschema; 访问的时候需要写成schema_name.table_name的形式,比如 select * from sche 阅读全文
posted @ 2022-06-22 14:40 南大仙 阅读(5387) 评论(0) 推荐(0) 编辑
摘要:行级安全策略可以配置表中的那些数据可以被那些用户进行某种操作,比如rsl表中的name=aa的数据可以让a1看到 using 针对已经存在的记录的校验. 可实施在select, update, delete, ALL上 whth check 针对将要新增的记录的校验, 可实施在insert, upd 阅读全文
posted @ 2022-06-22 10:16 南大仙 阅读(224) 评论(0) 推荐(0) 编辑
摘要:添加列 新加的字段为默认值,如果没有默认值,则会自动默认为空 mydb=# select * from products; product_no | name | price + + 1 | aaa | 2.11 1 | aa | (2 rows) mydb=# ALTER TABLE produc 阅读全文
posted @ 2022-06-21 11:44 南大仙 阅读(219) 评论(0) 推荐(0) 编辑
摘要:约束 mydb=# CREATE TABLE products (product_no integer,name text,price numeric CHECK (price > 0)); //添加约束 price > 0 CREATE TABLE mydb=# mydb=# mydb=# ins 阅读全文
posted @ 2022-06-21 11:21 南大仙 阅读(161) 评论(0) 推荐(0) 编辑
摘要:postgresql隐藏字段 在 PostgreSQL 中,当我们创建一个数据表时,数据库会隐式增加几个字段。这些字段由数据库系自动维护,用户一般不会感知 tableoid ctid xmin xmax cmin cmax oid tableoid 包含这一行的表的OID。该列是特别为从继承层次(见 阅读全文
posted @ 2022-06-20 17:06 南大仙 阅读(1161) 评论(0) 推荐(0) 编辑
摘要:我们在分组后,可以查出分组中复合条件的count,以及分组的count。 postgres=# create table test(id int, c1 int); CREATE TABLE postgres=# insert into test select generate_series(1,1 阅读全文
posted @ 2022-06-20 16:23 南大仙 阅读(886) 评论(0) 推荐(0) 编辑
摘要:standard_conforming_strings=on,\失去了转义的意思,即‘’中是什么就是什么,但是standard_conforming_strings=off时,\会保留转义的含义所以select '\'即为'' 在Unicode转义语法中,反斜杠后的任何其他字符均按字面意义使用。因此 阅读全文
posted @ 2022-06-20 10:30 南大仙 阅读(453) 评论(0) 推荐(0) 编辑
摘要:PostgreSQL Unicode标识符 mydb=# select U&"\0044\0061\0054\+000061" UESCAPE '\'; ERROR: column "DaTa" does not exist LINE 1: select U&"\0044\0061\0054\+00 阅读全文
posted @ 2022-06-20 10:11 南大仙 阅读(22) 评论(0) 推荐(0) 编辑
摘要:postgresql内核日志格式为postgresql-2022-06-07_081953.log log_filename = 'PostgreSQL-%Y-%m-%d.log' PostgreSQL-%Y-%m-%d.log中的%Y%m%d格式如下解释 Linux日期格式 date +%Y%m% 阅读全文
posted @ 2022-06-09 10:19 南大仙 阅读(180) 评论(0) 推荐(0) 编辑