首页 > 技术文章 > PostgreSql基础命令及问题总结

nopnog 2017-10-30 19:43 原文

 

本章内容:

  1、基本命令

 

基本命令 

  1、psql -U cdnetworks_beian -d cdnetworks_beian         #-U指定用户,-d指定数据库

  2、\l                   #相当于show databases;

  3、\d                  #想当与show tables;

       \d后面跟一个表名,表示显示这个表的结构定义 

    \db       #显示创建的tablespace 

  4、DROP TABLE table_name              #删除表

  5、CREATE DATABASE dbname          #创建数据库

  6、DROP DATABASE                          #删除数据库

  7、CREATE TABLE DEPARTMENT(

                           ID INT PRIMARY KEY NOT NULL,

                       DEPT CHAR(50) NOT NULL,

            );

                                                              #创建表

 

  

 

Mac 安装postgreSql的启动方法

To migrate existing data from a previous major version of PostgreSQL, see:

  https://www.postgresql.org/docs/10/static/upgrading.html

  You will need your previous PostgreSQL installation from brew to perform

  `pg_upgrade` or `pg_dumpall` depending on your upgrade method.

  Do not run `brew cleanup postgresql` until you have performed the migration.

To have launchd start postgresql now and restart at login:

  brew services start postgresql

Or, if you don't want/need a background service you can just run:

  pg_ctl -D /usr/local/var/postgres start

==> Summary

推荐阅读