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语言,不是从hello world开始
开始看C语言,主要是复习,所以就没必要从hello world开始了,写点例子熟悉下就好了. 使用公式℃=(5/9)(℉-32)打印下列华氏温度与摄氏温度对照表: #include <stdio ...
- eclipse 弹出智能提示、代码自动换行
在eclipse 中编写java 程序时,为了快速查找变量或搜索方法调用,在智能窗口的帮助下,程序的编写速度会更快,但eclipse 默认下并不弹出智能窗口,这就需要自己进行配置,设置的步骤如下: 打 ...
- 检测zookeeper和kafka是否正常
cd $(dirname $) source ~/.bash_profile count_zoo=`ps -ef | grep "config/zookeeper.properties&qu ...
- Vmware ESX5i 环境下部署Windows Storage Server 2008 R2
ESX5i 环境下部署Windows Storage Server 2008 R2 Windows Storage Server 2008 这款产品微软早已发布,WSS2008是基于Win ...
- cordova local notification plugin
cordova plugin add org.apache.cordova.device cordova plugin add https://github.com/katzer/cordova-pl ...
- qemu-img convert -c -O qcow2 source.raw aim.qcow2
qemu-img convert -c -O qcow2 source.raw aim.qcow2 qemu-img create -f qcow2 -o preallocation=metadata ...
- JS常用的设计模式(7)—— 外观模式
外观模式(门面模式),是一种相对简单而又无处不在的模式.外观模式提供一个高层接口,这个接口使得客户端或子系统更加方便调用.用一段再简单不过的代码来表示 var getName = function() ...
- C# 正则表达式及常用正则表达式
元字符 描述 .点 匹配任何单个字符.例如正则表达式r.t匹配这些字符串:rat.rut.r t,但是不匹配root. $ 匹配行结束符.例如正则表达式weasel$ 能够匹配字符串"He' ...
- 配置DNS域名解析服务器
bind这个DNS域名解析服务器解析好后,执行下面的语句实现开启服务 named -c named.conf & -c指配置脚本named.conf的文件地址 named.conf主要有下面几 ...
- LLVM language 参考手册(译)(1)
LLVM Language Reference Manual 摘要 这个文档是一个LLVM汇编语言的参考手册.LLVM是一个基于Static Single Assignment(SSA - 静态单赋值 ...