当前位置:网站首页>PostgreSQL 初步了解(一)
PostgreSQL 初步了解(一)
2022-06-21 12:30:00 【2022冲鸭】
由于最近工作业务的需要,学习PG,被同事安利一本《PostgreSQL 修炼之道 从小工到专家》,就书中学习到自己觉得有用的摘录出来。
它类似于我之前接触过的Oracle 中的sqlplus ,一种终端工具
1.psql 工具
\d 查看当前数据库的所有表
\d + 显示更详细信息
\d t 显示这个表结构定义
\d tablename_pkey 显示索引信息
\timing on
select count(*) from temp;
显示SQL 已执行时间
\dn 显示所有schema
\db 显示表空间
指定字符集编译的命令:
当客户端字符集编码与服务器不一致,会显示乱码,
服务端:\encoding gbk; \encoding utf8
客户端: gbk utf8
\pset命令 设置输出格式
\pset border 0;输出内容无边框
\pset border 1;输出内容只在内容
\pset border 1;输出内容内外部都有边框
\x 把表中每一行数据拆分为单行
\i 文件名称 执行存储在外部文件的SQL文件
\echo 用于输出一行信息
psql 使用技巧
psql 中事物是自动提交,执行完一条delete 或者updata 语句,事物自动提交,如果不想提交的的解决办法:
1.begin -> dml语句 -> commit/rollback
2.使用命令行关闭 \set AUTOCOMMIT off (AUTOMINT 必须大些,虽然不会报错,但是此操作不起作用)
边栏推荐
- Educator web exercise - creating a text area
- Postgre SQL 支持的数据类型分类
- uva11729
- matplotlib 画图 Tips
- Inheritance and override of methods
- 愿山河无恙
- [100 unity pit knowledge points] | unity uses quaternion Angleaxis random one direction
- Practical application of ankerui BM100 series signal isolator
- Educoder table label - basic table structure
- uniapp中常用到的方法(部分) - 时间戳问题及富文本解析图片问题
猜你喜欢

Nanjing University static program analyses -- Introduction learning notes

Huawei cloud releases desktop ide codearts

Educoder Web练习题---交互元素

Router telnet and ACL configuration

About SDRAM memory

UML的六种关系-系统学习四

Technical scheme for environmental monitoring system of power distribution room

给表单组件添加说明

i. MX - rt1052 sdcard operation (SDIO interface)

Creation mode - singleton mode
随机推荐
Inheritance and override of methods
青龙面板,京东定时任务库,脚本库大全
UVA1203 Argus
深度学习实战(十):使用 PyTorch 进行 3D 医学图像分割
Redis maximum memory elimination strategy
方法的繼承和重寫
3D Slicer将分割结果保存
[100 unity practical skills] | obtain the coordinates of mouse clicks in the game and move the game object to the click position of the mouse
Educoder web exercises - structural elements
一文掌握SQLite3基本用法
Educoder Web练习题---对表单元素分组
自动弹出 微信授权登录窗口
卷积神经网络“卷积”的深层理解
Educator web exercises - grouping elements
在数字时代实现IT敏捷性的12个技巧
Redis personal summary concise version
看懂UML类图和时序图
TOOD: Task-aligned One-stage Object Detection
Standing at the digital tuyere, how can tooling enterprises "fly"
Nanjing University static program analyses -- intermediate representation learning notes