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终于让跨平台部署成为了现 ...
随机推荐
- MySQL数据分析(16)— 数据操作之增删改查
前面我们说学习MySQL要从三个层面,四大逻辑来学,三个层面就是库层面,表层面和数据层面对吧,数据库里放数据表,表里放数据是吧,大家可以回忆PPT中jacky的这图,我们已经学完了库层面和表层面,从本 ...
- 解决node-sass无法下载的问题
本文链接:https://blog.csdn.net/qq383366204/article/details/86605960在国内用npm安装依赖的时候经常都会有各种奇怪的问题,个人强烈推荐用yar ...
- c++ 实现等待5s
#include <stdio.h> /* puts, printf */ #include <time.h> /* time_t, struct tm, time, loca ...
- 服务器 Web服务器 应用服务器区别联系
服务器: 通俗的讲,我们访问一个网站就相当于访问一个服务器的文件,如果想要通过自己的域名来访问一个网站,首先得将域名部署到你的服务器上,然后就可以通过域名访问到你服务器上的网 页文件.ip地址就相当于 ...
- 运维自动化之ansible
Ansible简介 Ansible是一个简单的自动化运维管理工具,基于Python语言实现,由Paramiko和PyYAML两个关键模块构建,可用于自动化部署应用.配置.编排task(持续交付.无宕机 ...
- idhttp访问HTTPS
idhttp访问HTTPS 访问一个 WEB 网站,如果采用 HTTP 的话,直接使用 TIdHTTP 这个控件,最简单的用法是: S := IdHTTP1.Get('www.qq.com'); 这里 ...
- 回归regression
X-Y存在某种映射关系,回归:确定出关系模型.
- Servlet的概述
A: Servlet的概述: server applet , 是一个运行在服务器端的小应用程序 B: 就是一个接口,作用: servlet 通常通过 HTTP(超文本传输协议)接收和响应来自 Web ...
- Node.js使用Express实现Get和Post请求
var express = require('express'); var app = express(); // 主页输出 "Hello World" app.get('/', ...
- Spring Aop(九)——基于正则表达式的Pointcut
转发地址:https://www.iteye.com/blog/elim-2396525 基于正则表达式的Pointcut JdkRegexpMethodPointcut Spring官方为我们提供了 ...