PostgreSQL练习3
select dname,count(ename),avg(sal),sum(sal)
from emp e,dept d
where e.deptno=d.deptno
group by dname;
select dname,count(ename),avg(sal),sum(sal)
from emp e inner join dept d
on e.deptno=d.deptno
group by dname;
psql -h 192.168.0.100 -U testuser
create database testdb
\c testdb
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02')
intersect
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02')
intersect all
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02')
union all
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02')
union
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02')
union all
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02')
except
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
SELECT *
FROM sdb."Student" as a
where a.Sid in ('01','02','03')
except all
SELECT *
FROM sdb."Student" as b
where b.Sid in ('01')
select s.Sid
FROM sdb."Student" as s
left join sdb.sc
on s.Sid=sc.Sid
group by s.Sid
having count(sc.Cid)<(select count(Cid) from sdb.course);
select abs(-11);
select mod(123,6);
select ceil(1.1);
select floor(1.9);
select round(123.123,0);
select trunc(123.123,3);
select ascii('A');
select chr(66);
select lower('SQL');
select upper('asd');
select initcap('sda');
select substr('asdfgh',2,3);
select length('SQL');
select position('r'in 'string');
select lpad('h',10,'*');
select rpad('g',10,'*');
select trim('s'from 'string');
select replace('ASD','SD','sd');
select current_date;
select current_time;
select extract(day from timestamp '2019-10-17 14:05:40');--从日期时间轴里抽取子域
select date_trunc ('month',now());
select current_time+time'00:00:01';
select current_time+time'00:01';
select current_time+time'01:00';
select current_time+interval'1 day';
select current_time+interval'1 week';
select current_time+interval'1 month';
select to_char(current_timestamp,'HH12:MI:SS');
select to_char(interval'15h 2m 12s','HH24:MI:SS');
select to_char(125,'999');
select to_char(125.8::real,'99909');
select to_date('05 Dec 2000','DD MON YYYY');
select to_number('12.454.8-','99G999D99S');
select to_timestamp('05 Dec 2000','DD MON YYYY');
select current_database();--当前数据库名字
select current_schema();--当前模式名字
select current_user;--当前环境下用户名
select version();--版本信息
PostgreSQL练习3的更多相关文章
- postgresql 基本语法
postgresql数据库创建/修改/删除等写入类代码语法总结: 1,创建库 2,创建/删除表 2.1 创建表 create table myTableName 2.2 如果表不存在则创建表 crea ...
- postgresql无法安装pldbgapi的问题
要对函数进行调试需要安装插件pldbgapi,当初在windows上面的postgresql实例中执行了一下语句就安装上了: create extension pldbgapi; 但是在linux中执 ...
- ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库
前段时间在园子里看到了小蝶惊鸿 发布的有关绿色版的Linux.NET——“Jws.Mono”.由于我对.Net程序跑在Linux上非常感兴趣,自己也看了一些有关mono的资料,但是一直没有时间抽出时间 ...
- MongoDB与PostgresQL无责任初步测试
PostgresQL一秒能插入多少条记录,MongoDB呢?读取的情况又如何?我写了一些简单的程序,得出了一些简单的数据,贴在这里分享,继续往下阅读前请注意下本文标题中的“无责任”,这表示此测试结果不 ...
- [PostgreSQL] 图解安装 PostgreSQL
图解安装 PostgreSQL [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5894462.html 序 园友的一篇<Asp.Net Cor ...
- Asp.Net Core 项目实战之权限管理系统(3) 通过EntityFramework Core使用PostgreSQL
0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之 ...
- PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库
最近准备下PostgreSQL数据库开发的相关知识,本文把总结的PPT内容通过博客记录分享,本随笔的主要内容是介绍PostgreSQL数据库的基础信息,以及如何在我们的开发框架中使用PostgreSQ ...
- PostgreSql性能测试
# PostgreSql性能测试 ## 1. 环境+ 版本:9.4.9+ 系统:OS X 10.11.5+ CPU:Core i5 2.7G+ 内存:16G+ 硬盘:256G SSD ## 2. 测试 ...
- postgresql 导出数据字典文档
项目上需要整理目前数据库的数据字典文档.项目不规范,这种文档只要后期来补.这么多张表,每个字段都写到word文档里真心头大.就算前面写了个查询表结构的sql,但是最后整理到word里还是感觉有点麻烦. ...
- CentOS7下安装并简单设置PostgreSQL笔记
为什么是PostgreSQL? 在.NET Core诞生之前,微软平台上最常见的开发组件便是.NET Framework + SQL Server了,但是现在.NET Core终于让跨平台部署成为了现 ...
随机推荐
- 使用zabbix-proxy
事情背景: vt上两个vps,只提供ipv6.(因为便宜嘛).而我的zabbix服务器在腾讯云.它丫的没有ipv6. 那么我没法监控它们了呀... 这咋个行呢? 想办法... 我还有另外的vps 可以 ...
- wqy的B题
wqy的B题 题意: 和一道叫机器翻译的题差不多,不过这道题要难一些,没有规定必须删除最早入队的. 解法: 解法和[POI2005]SAM-Toy Cars这道题差不多,考虑贪心. 每次选取下一次使用 ...
- Leetcode题目543:二叉树的直径(简单)
题目描述: 给定一棵二叉树,你需要计算它的直径长度.一棵二叉树的直径长度是任意两个结点路径长度中的最大值.这条路径可能穿过根结点. 示例 :给定二叉树 1 / \ 2 3 / \ 4 5 返回 3, ...
- 基本PSO算法实现(Java)
一.算法流程 Step1:初始化一群粒子(粒子个数为50个),包括随即位置和速度: Step2:计算每个粒子的适应度fitness: Step3:对每个粒子,将其适应度与其进过的最好位置(局部)pbe ...
- 文件上传对servlet的要求
request.getParamter(String name)方法不能再使用了 需要使用request.getInputStream()获取输入流对象然后在进行读取数据 解析数据 ServletIn ...
- OSG Qt Widget加载三维模型
graphicswindowqt.h #ifndef GRAPHICSWINDOWQT_H #define GRAPHICSWINDOWQT_H #include <QGLWidget> ...
- python3 __mian和__name__的区别
1.新建 test.py 模块: def GetModuleName(): print('__name__ = ', __name__) def PrintName(): print('PrintNa ...
- iOS- UITextView禁止Emoji表情
UITextView代理方法:判断 -(void)textViewDidEndEditing:(UITextView *)textView{ if ([self stringContai ...
- Go单引号和双引号区别
首先做个测试,看下面那个选项是正确的: A. str:='abc'+'123'B. str:="abc"+"123"C. str:='123'+"ab ...
- 【ABAP系列】SAP ABAP BAPI_REQUISITION_CREATE创建采购申请
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI_RE ...