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 ...
随机推荐
- Jackson 框架,轻易转换JSON(转)
Jackson可以轻松的将Java对象转换成json对象和xml文档,同样也可以将json.xml转换成Java对象. 相比json-lib框架,Jackson所依赖的jar包较少,简单易用并且性能也 ...
- Java垃圾收集器之--Garbage-First Collector
简介 Garbage-First(G1)垃圾收集器全面支持JDK7 Upate 4及后续版本.G1收集器是一个服务器形式(server-style)的垃圾收集器,主要用于内存大.多处理器的 ...
- 慕课网-安卓工程师初养成-4-6 Java条件语句之 switch
来源:http://www.imooc.com/code/1358 当需要对选项进行等值判断时,使用 switch 语句更加简洁明了.例如:根据考试的名次,给予前 4 名不同的奖品.第一名,奖励笔记本 ...
- SQL基本语句(3) LOAD DATA INFILE
使用LOAD语句批量录入数据 语法: LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' [REPLACE | IGNOR ...
- 学习总结 Java 基本数据类型 和标识符以及常用的关键字
思维导图: public static void main(String[] args) { // java程序的入口点 c#是Main System.out.println("测试输出&q ...
- Andriod基础——Adapter类
Android是完全遵循MVC模式设计的框架,Activity是Controller,layout是View,因为layout五花八门,很多数据都不能直接绑定上去,所以Android引入了Adapte ...
- devexpress中应用于girdviw中HtmlDataCellPrepared事件与CellEditorInitialize事件的区别
HtmlDataCellPrepared 事件为页面展示的时候对页面做的初始化(将id变为name) CellEditorInitialize 事件为页面在编辑时(新增.修改)时做的初始化,如将值填 ...
- 简单的TCPIP 客户端 服务器
// soClient.cpp : Defines the entry point for the console application. // #include "stdafx.h&qu ...
- iOS 平台开发OpenGL ES程序注意事项
本人最近从Android平台的OpenGL ES开发转到iOS平台的OpenGL ES开发,由于平台不同,所以开发中会有一些区别,再次列出需要注意的几点. 1.首先需要了解iOS主要开发框架,再次仅介 ...
- Threatening letter in Naver Line App
A suspect sent a threatening letter in Naver Line App to Richman, and said that he wanted those mone ...