Postgres Basic Commands for Beginners
Just sharing what I have learned about postgres recently. Here is a part of basic commands you may need. Enjoy it!
Before try the following commands, please ensure you are followed the introductions on github: https://github.com/thoughtworks/vagrant-postgresql.
1. boot up a database by virtualBox and vagrant
script/database up

2. login the postgres
psql -h hostname -U username
psql -h localhost -U postgres

Note: password: it depends. Maybe "postgres" or "password" or "secret".
3. list all the databases
\l or \list

4. list all the roles
\du

5. for help
"\h" or "\?" or "help"
it depends on the context.
6. create a new database
create database databasename
create database mydb;

list all the databases, and you can find the database just created.

7. connect to the database
\c databasename
\c mydb
or \connect mydb

8. create a table
create table users (user_id bigserial primary key, user_name varchar(20) not null );
Note: auto_increment is a MySQL feature. Postgres uses serial columns for the same purpose.

9. list tables in connected database
\dt

10. list the schema of a table
\d tablename
\d users

11. get current database name
select current_database();

……
Hopefully these commands will help you getting started with postgres command line quickly. For more information, please feel free to discuss with me or turn to these website:
http://www.postgresql.org/docs/9.1/static/app-psql.html,
http://www.commandprompt.com/ppbook/c4890
Postgres Basic Commands for Beginners的更多相关文章
- Network Basic Commands Summary
Network Basic Commands Summary set or modify hostname a) temporary ways hostname NEW_HOSTNAME, b ...
- Linux--Introduction and Basic commands(Part one)
Welcome to Linux world! Introduction and Basic commands--Part one J.C 2018.3.11 Chapter 1 What Is Li ...
- CheeseZH: Octave basic commands
1.Basic Operations 5+6 3-2 5*8 1/2 2^6 1 == 2 %false ans = 0 1 ~= 2 %true ans = 1 1 && 0 %AN ...
- linux basic commands
1. man - an interface to the on-line reference manuals $man man 2. apt - advanced package tool SEE A ...
- kafka basic commands
kafka-server-start.sh config/server.properties & kafka-server-stop.sh kafka-topics.sh --creat ...
- Kali Basic Configuration
1:Kali Version root@kali-node01:~# cat /etc/os-release PRETTY_NAME="Kali GNU/Linux Rolling" ...
- 13 Basic Cat Command Examples in Linux
FROM: http://www.tecmint.com/13-basic-cat-command-examples-in-linux/ The cat (short for “concatenate ...
- 【转】Redis入门
Redis是一个开源,先进的key-value存储,并用于构建高性能,可扩展的Web应用程序的完美解决方案. Redis从它的许多竞争继承来的三个主要特点: Redis数据库完全在内存中,使用磁盘仅用 ...
- ubuntu包管理
查看某个文件属于哪个包dpkg -S add-apt-repository 包名software-properties-common命令名/usr/bin/add-apt-repository/usr ...
随机推荐
- c# 生成json数据包
json数据类型,归根到底就是一个字符串,管他里面什么格式,它就是一个字符串来的! 看一个json数据包: { "touser":"OPENID", " ...
- EB(存储单位)
abbr.艾字节,1EB=1024PB 计算机的存储单位 位 bit (比特)(Binary Digits):存放一位二进制数,即 0 或 1,最小的存储单位. 字节 byte:8个二进制位为一个字节 ...
- php函数将对象转换为数组以及json_decode的使用技巧
在写php代码的时候,发现调用接口返回的结果类型是对象,不是自己想要的数组,于是乎,写了一个将对象转化数组的函数: /** * 将对象转化为数组 */ private function objectT ...
- dll显式加载与隐式加载
使用动态DLL有两种方法,一种是隐式链接,一种是显式链接,如果用loadlibrary就是显示链接,用lib就属于隐式链接. 两种方法对于你的程序调用动态库时没有任何区别,只是你在编程时,步骤是不一样 ...
- CHARINDEX用法
CHARINDEX返回字符串中指定表达式的起始位置. 语法CHARINDEX ( expression1 , expression2 [ , start_location ] ) 参数expre ...
- IBM Tivoli NetView网管软件实战
广大网络管理者需要一款包括网络监控故障处理的一个集成网络管理平台,本文根据作者多年实践提出的基于IBM Tivoli Netview的综合网络管理平台,IBM Tivoli与Cisco一直保持着良好的 ...
- 集群监控系统Ganglia应用案例
集群监控系统Ganglia应用案例 --我们把集群系统投入生产环境后,这时就需要一套可视化的工具来监视集群系统,这将有助于我们迅速地了解机群的整体配置情况,准确地把握机群各个监控节点的信息,全面地察看 ...
- rel="stylesheet" 描述
<link type="text/css" rel="stylesheet" href="css/style.css"/> re ...
- jquery ajax 保存讲解
jquery ajax 参数传递与数据保存实例是一款适合于初学者用的,首先我们是讲一下关于如何利用ajax +php进行数据操作,然后再详细的介绍关于jquery ajax的帮助说明. jquery ...
- CentOS下通过rdesktop连接Windows远程桌面
众所周知,微软的Windows提供了一种远程桌面系统(Remote Desktop),该服务的默认端口是3389,可使用户远程登录进行系统管理或作为终端服务器运行各种应用软件. 而要连接Windows ...