方法一:
[postgres@node01 ~]$ psql -Upostgres
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
test | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows) postgres=# \c test
You are now connected to database "test" as user "postgres".
test=# \i /stage/company.sql
DROP TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
test=# select * from company;
id | name | age | address | salary
----+-------+-----+----------------------------------------------------+--------
1 | Paul | 32 | California | 20000
2 | Allen | 25 | Texas | 15000
3 | Teddy | 23 | Norway | 20000
4 | Mark | 25 | Rich-Mond | 65000
5 | David | 27 | Texas | 85000
6 | Kim | 22 | South-Hall | 45000
7 | James | 24 | Houston | 10000
(7 rows) 方法二:
[postgres@node01 ~]$ psql -Upostgres -d test0 -f /stage/company.sql
DROP TABLE
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
[postgres@node01 ~]$ psql -Upostgres
psql.bin (10.14)
Type "help" for help. postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
test | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
test0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(5 rows) postgres=# \c test0
You are now connected to database "test0" as user "postgres".
test0=# \d
List of relations
Schema | Name | Type | Owner
--------+---------+-------+----------
public | company | table | postgres
(1 row) test0=# select * from company;
id | name | age | address | salary
----+-------+-----+----------------------------------------------------+--------
1 | Paul | 32 | California | 20000
2 | Allen | 25 | Texas | 15000
3 | Teddy | 23 | Norway | 20000
4 | Mark | 25 | Rich-Mond | 65000
5 | David | 27 | Texas | 85000
6 | Kim | 22 | South-Hall | 45000
7 | James | 24 | Houston | 10000
(7 rows)

  

最新文章

  1. ASP.NET MVC5+EF6+EasyUI 后台管理系统(73)-微信公众平台开发-消息管理
  2. ASP.NET Core 中文文档 第二章 指南(3)用 Visual Studio 发布一个 Azure 云 Web 应用程序
  3. Codeforces Round #354 (Div. 2)
  4. WinDbg 命令三部曲:(三)WinDbg SOSEX 扩展命令手册
  5. FL2440驱动添加(2): RTC(Real time clock)
  6. amcharts简单封装
  7. [原创]SQL SERVER 2008R2 技术总结专题目录索引
  8. java中时间格式yyyyMMddHHmmss的大小写问题
  9. BZOJ 1741: [Usaco2005 nov]Asteroids 穿越小行星群
  10. 【转】Word中使用Endnote很卡解决方案
  11. Spark:一个独立应用
  12. JSTL标签库的基本教程之核心标签库(一)
  13. H5学习之旅-H5的块标签的使用(9)
  14. 精通Dubbo——Dubbo支持的协议的详解
  15. C#通过Ado.net对连接数据库并进行添加删除等常规操作的代码
  16. python基础学习1(linux命令)
  17. goroutine 知识点
  18. set names utf8;
  19. IoC之Ninject
  20. Java Iterator的一般用法

热门文章

  1. windows 无法启动 SQL Server (MSSQLSERVER) 服务(位于本地计算机上)。错误 1069由于登入失败而无法启动 。
  2. 单线程的Redis有哪些慢动作?
  3. javascript布局转换
  4. kali 系列学习09-Kali-linux设置ProxyChains
  5. mysql密码问题
  6. Spring Cloud实战 | 第九篇:Spring Cloud整合Spring Security OAuth2认证服务器统一认证自定义异常处理
  7. 4.1 Spring源码 --- 监听器的原理
  8. Network_01
  9. 如何用OCR文字识别软件将PDF转换成Excel
  10. 中级实训Android学习记录——Toast、AlertDialog、ProgressBar