---
title: "PostgreSQL 基本操作"
author: "maxer025"
date: "2019-03-09T03:07:28Z"
tags: []
categories: ["非技术"]
slug: "postgresql"
draft: false
lastmod: "2019-03-09T03:07:28Z"
id: 2438634
url: "https://maxer025.iteye.com/blog/2438634"
---

PostgreSQL操作-psql基本命令

一、建立数据库连接
----------------
接入PostgreSQL数据库: psql -h IP地址 -p 端口 -U 数据库名

之后会要求输入数据库密码

 

二、访问数据库

1、列举数据库：\l
2、选择数据库：\c 数据库名
3、查看该某个库中的所有表：\dt
4、切换数据库：\c interface
5、查看某个库中的某个表结构：\d 表名
6、查看某个库中某个表的记录：select * from apps limit 1;
7、显示字符集：\encoding
8、退出psgl：\q