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终于让跨平台部署成为了现 ...
随机推荐
- 十六、程序包管理之 rpm
c语言程序的构建过程 1.程序源代码 --> 预处理 --> 编译 --> 汇编 --> 链接--> 可执行程序 开放源码:就是程序码,文本格式的源代码,写给人类看的程序 ...
- 在AspNetCore3.0中使用Autofac
1. 引入Nuget包 Autofac Autofac.Extensions.DependencyInjection 2. 修改Program.cs 将默认ServiceProviderFactory ...
- 编写第一个Servlet程序
在开始这一节之前呢,我们还需要把Tomcat配置到Eclipse中,配置的方式很简单,打开Eclipse,Window,Preferences,进入到这个页面 将Tomcat的安装目录配置到Eclip ...
- eclipse使用正则表达式查找替换
1,Eclipse ctrl+f 打开查找框2,选中 Regular expressions (正则表达式) 去掉/* */(eclipse) /\*(.|[\r\n])*?\*/去掉/ ...
- 【Robot Framework 项目实战 02】使用脚本生成统一格式的RF关键字
背景 在微服务化的调用环境下,测试数据及接口依赖的维护是一个问题,因为依赖的接口和数据可能不在同一个服务下,而这相关的多个服务往往是不同人员来测试的. 因此为了节省沟通成本,避免关键字的重复冗余.所以 ...
- AddLayer和AddTag
using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; pu ...
- JavaScript作用域与闭包总结
1.全局作用域 所有浏览器都支持 window 对象,它表示浏览器窗口,JavaScript 全局对象.函数以及变量均自动成为 window 对象的成员.所以,全局变量是 window 对象的属性,全 ...
- XML解析思想
获取文档中的数据: 反序列化[巧记:反读] 把内存中的数据存储到文档中: 序列化[巧记:序写] XML解析思想 DOM: 就是将文档中的数据全部加载到内存,在内存中形成DOM树,然后对数据进行增删改查 ...
- java调用js脚本
有些情况下,需要java去调用js,groovy等脚本语言,传入参数获取脚本运行的结果. js脚本例子: function add(a,b){ return a + b + number; } jav ...
- 去除表视图section的粘性问题
// 去除section的粘性 - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ if (scrollView == self.tabl ...