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的更多相关文章

  1. postgresql 基本语法

    postgresql数据库创建/修改/删除等写入类代码语法总结: 1,创建库 2,创建/删除表 2.1 创建表 create table myTableName 2.2 如果表不存在则创建表 crea ...

  2. postgresql无法安装pldbgapi的问题

    要对函数进行调试需要安装插件pldbgapi,当初在windows上面的postgresql实例中执行了一下语句就安装上了: create extension pldbgapi; 但是在linux中执 ...

  3. ASP.NET MVC 使用 Petapoco 微型ORM框架+NpgSql驱动连接 PostgreSQL数据库

    前段时间在园子里看到了小蝶惊鸿 发布的有关绿色版的Linux.NET——“Jws.Mono”.由于我对.Net程序跑在Linux上非常感兴趣,自己也看了一些有关mono的资料,但是一直没有时间抽出时间 ...

  4. MongoDB与PostgresQL无责任初步测试

    PostgresQL一秒能插入多少条记录,MongoDB呢?读取的情况又如何?我写了一些简单的程序,得出了一些简单的数据,贴在这里分享,继续往下阅读前请注意下本文标题中的“无责任”,这表示此测试结果不 ...

  5. [PostgreSQL] 图解安装 PostgreSQL

    图解安装 PostgreSQL [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5894462.html 序 园友的一篇<Asp.Net Cor ...

  6. Asp.Net Core 项目实战之权限管理系统(3) 通过EntityFramework Core使用PostgreSQL

    0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之 ...

  7. PostgreSQL介绍以及如何开发框架中使用PostgreSQL数据库

    最近准备下PostgreSQL数据库开发的相关知识,本文把总结的PPT内容通过博客记录分享,本随笔的主要内容是介绍PostgreSQL数据库的基础信息,以及如何在我们的开发框架中使用PostgreSQ ...

  8. PostgreSql性能测试

    # PostgreSql性能测试 ## 1. 环境+ 版本:9.4.9+ 系统:OS X 10.11.5+ CPU:Core i5 2.7G+ 内存:16G+ 硬盘:256G SSD ## 2. 测试 ...

  9. postgresql 导出数据字典文档

    项目上需要整理目前数据库的数据字典文档.项目不规范,这种文档只要后期来补.这么多张表,每个字段都写到word文档里真心头大.就算前面写了个查询表结构的sql,但是最后整理到word里还是感觉有点麻烦. ...

  10. CentOS7下安装并简单设置PostgreSQL笔记

    为什么是PostgreSQL? 在.NET Core诞生之前,微软平台上最常见的开发组件便是.NET Framework + SQL Server了,但是现在.NET Core终于让跨平台部署成为了现 ...

随机推荐

  1. spark学习笔记之面试

    spark常见面试 map与flatMap的区别 题:以下代码输出有什么不同 val books=List("Hadoop","Hive","HDFS ...

  2. Win内核原理与实现学习笔记1-windows内核版本列表

  3. golang中文件以及文件夹路径相关操作

    获取目录中所有文件使用包: io/ioutil 使用方法: ioutil.ReadDir 读取目录 dirmane 中的所有目录和文件(不包括子目录) 返回读取到的文件的信息列表和读取过程中遇到的任何 ...

  4. Netty实践场景

    数据通信 如果需要考虑的是两台机器(甚至多台)怎么使用Netty进行通信.大体上分为三种: 1 第一种:使用长连接通道不断开的形式进行通信.也就是服务端和客户端的通道一直处于开启状态. 如果服务器性能 ...

  5. python+Django+mysql环境搭建

    为什么我的毕业设计还要用到网站啊啊啊啊.什么鬼啊,又要做爱拍拍又要做网站???饶了我啊..我选择狗带.. 网站就用django做吧,毕竟之前做过一个电脑销售网站,希望能借鉴一下经验什么的,不要一切从头 ...

  6. mysql中的union操作(整理)

    mysql中的union操作(整理) 一.总结 一句话总结: union两侧的字段数和字段类型要是一样的 union可以接多个 orderby和排序可以在最后的union组合之后 1.union简单实 ...

  7. Programming a Hearthstone agent using Monte Carlo Tree Search(chapter one)

    Markus Heikki AnderssonHåkon HelgesenHesselberg Master of Science in Computer Science Submission dat ...

  8. DBeaver 客户端中时间显示问题解决

    最近工作使用了一段时间的macOS,换了新的数据库客户端 DBeaver,无意中发现客户端显示时间不正确.时间保存之后显示比实际时间多13个小时整.可以判断是时区没有配置正确.无意中发现是DBeave ...

  9. 使用ffmpeg裁剪和合并视频

    剪切视频 使用 -ss 和 -t 选项,从第0秒开始,向后截取31秒视频,并保存 ffmpeg -ss :: -i video.mp4 -vcodec copy -acodec copy -t :: ...

  10. java8:(Lambda 表达式简介)

    JDK8的新特性——Lambda表达式 JDK8已经发布快4年的时间了,现在来谈它的新特性显得略微的有点“不合时宜”.尽管JDK8已不再“新”,但它的重要特性之一——Lambda表达式依然是不被大部分 ...