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的更多相关文章

  1. Network Basic Commands Summary

    Network Basic Commands Summary set or modify hostname a)     temporary ways hostname NEW_HOSTNAME, b ...

  2. 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 ...

  3. 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 ...

  4. linux basic commands

    1. man - an interface to the on-line reference manuals $man man 2. apt - advanced package tool SEE A ...

  5. kafka basic commands

    kafka-server-start.sh config/server.properties & kafka-server-stop.sh kafka-topics.sh    --creat ...

  6. Kali Basic Configuration

    1:Kali Version root@kali-node01:~# cat /etc/os-release PRETTY_NAME="Kali GNU/Linux Rolling" ...

  7. 13 Basic Cat Command Examples in Linux

    FROM: http://www.tecmint.com/13-basic-cat-command-examples-in-linux/ The cat (short for “concatenate ...

  8. 【转】Redis入门

    Redis是一个开源,先进的key-value存储,并用于构建高性能,可扩展的Web应用程序的完美解决方案. Redis从它的许多竞争继承来的三个主要特点: Redis数据库完全在内存中,使用磁盘仅用 ...

  9. ubuntu包管理

    查看某个文件属于哪个包dpkg -S add-apt-repository 包名software-properties-common命令名/usr/bin/add-apt-repository/usr ...

随机推荐

  1. svn 终端命令

    你可以仅仅删除冲突的文件并且提交,但是svn resolved除了删除冲突文件,还修正了一些记录在工作拷贝管理区域的记录数据,所以我们推荐你使用这个命令. 恢复本地修改  svn revert [-- ...

  2. 菜鸟学四轴控制器之3:数字积分法DDA实现直线插补

    上一篇的逐点比较法显然是无法画一条有倾角的直线的.因为X轴和Y轴永远都不同步,也就是像打台球一样,你打一个,我打一个,如果我进了球,我再接着打一个. 也就是说,如果直线为45度,也是没有办法画出来的, ...

  3. windows 服务的启动与安装

    在使用windows 操作系统时,我们对windows服务再也熟悉不过了,这些服务有的是系统层的,有的是应用层的,大部分都是运行在桌面的后台,可以在进程中看到,有时候在做web项目时,在站点启动时要启 ...

  4. phpDoc使用说明

    技术文档可以使人们更好得使用他人的代码库,然而,作为开发人员,编写文档确是一件让人头疼的事情.PHPDoc是PHP文档注释的一个标准,它可以实现为代码生成API文档. PHPDoc注释规范: 块注释的 ...

  5. log4

    <?xml version="1.0"?> <configuration> <configSections> <section name= ...

  6. Android基础总结(7)——异步消息处理

    服务(Service)是Android中实现程序后台运行的解决方案,它非常适合用于去执行哪些不需要和用户交互而且还要长期运行的任务.服务的运行不依赖任何用户界面,即使当程序被切换到后台,或者用户打开了 ...

  7. TCP/IP详解学习笔记(7)-- 初识运输层

    作为TCP和UDP协议的学习前奏,简单的介绍一下运输层的相关内容,方便对TCP,UDP的学习. 1.概述      运输层的任务主要是负责主机中两个进程之间的通信.      运输层的基本功能: 复用 ...

  8. Avl树的基本操作(c语言实现)

    #include<stdio.h> #include<stdlib.h> typedef struct AvlNode *Position; typedef struct Av ...

  9. jsp页面el表达式不起作用

    web.xml中2.4版本的默认导入的standerd.jar,和jstl.jar是使用el表达式的包是启动的而2.5版本的web.xml中默认是关闭的所以在2.5的所有jsp中需要启动一下用< ...

  10. Linux FTP服务器搭建与使用

    一.vsftpd说明 LINUX下实现FTP服务的软件很多,最常见的有vsftpd,Wu-ftpd和Proftp等.Red Hat Enterprise Linux中默认安装的是vsftpd. 访问F ...