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 ...
随机推荐
- 【转载】Myeclipse如何自动创建hibernate
Myeclipse如何自动创建hibernate:http://jingyan.baidu.com/article/456c463b99f4370a583144a8.html An internal ...
- 将U盘分成 启动盘+文件存储区
我看了很多帖子,发现想要将U盘分区的朋友绝大部分是和我一样,想用U盘做成一个启动盘同时兼顾文件存储,分区的目的很简单,就是想将启动部分单独做成一个区,以免在日常的应用中使得启动文件染毒或者误操作造成损 ...
- IList,IQeurable,IEnumble和List 的区别
IList,IQeurable,IEnumble和List 的区别主要如下: 1.IList(IList<T>)会立即在内存里创建持久数据,这就没有实现“延期执行(deferred exe ...
- 使用PetaPoco ORM 框架分页查询
通过在派生的Repository中调用GetPagingEntities方法来获取分页数据,并返回由PagingDataSet<T>封装分页集合,例如: Public PagingData ...
- 常用思科设备图标(JPG+矢量图)
常用思科设备图标 在制作网络拓扑图示时我们利用MS Visio或亿图图示等制图软件自带的网络设备绘制拓扑图感觉提供的设备图标非常有限,往往不满足我们的要求,这时就常需要找一些思科的设备图标,在网上到处 ...
- 用pxe启动iso光盘里的pe
用pxe启动iso光盘里的pe 我不是个运维,所以pxe我是由于一台比较老的笔记本不能u盘启动.光驱又坏了的情况下,硬盘上的系统在我不小心下...ghostexp解压ghost文件到c盘的时候,c盘是 ...
- 【MariaDB】MariaDB编译参数
参考: http://wangfeng7399.blog.51cto.com/3518031/1393146?utm_source=tuicool http://www.phperz.com/arti ...
- 配置Android环境遇到的问题及解决办法
配置Android环境遇到的问题及解决办法: 1 环境安装地址 http://pan.baidu.com/s/1jGzNzyI 2 其他: 2.1 安装 2.1.1 安装JDK,JRE 成功安装之后, ...
- MVC组件分析(转)
2System.Web.Mvc V 4.0.0.0 组件分析 2.1 Routing组件(路由选择) Routing的作用就是负责分析Url Action的要求• 必须是一个公有方法• 必须返回Act ...
- leetcode 83
83. Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such that e ...