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 ...
随机推荐
- 【练习】sqlnet.ora
在SQLNET.ora文件中设置以下参数可以实现IP访问限制: $ pwd/u01/app/oracle/product/10.2.0/db_1/network/admin$ vi sqlnet.or ...
- SVN中文件属性
从SVN中checkout代码,然后设置crontab 定时执行脚本,发现permission denied 查看发现脚本没有可执行权限 但是,之前项目中的代码是有该权限的,于是猜想应该可以对SVN中 ...
- android service 学习
参考:http://www.cnblogs.com/allin/archive/2010/05/15/1736458.html http://www.cnblogs.com/allin/archive ...
- Scrapy安装、爬虫入门教程、爬虫实例(豆瓣电影爬虫)
Scrapy在window上的安装教程见下面的链接:Scrapy安装教程 上述安装教程已实践,可行.(本来打算在ubuntu上安装Scrapy的,但是Ubuntu 磁盘空间太少了,还没扩展磁盘空间,所 ...
- linux设备分类
网络设备:常见的有以太网卡.CAN总线.WIFI.蓝牙 重要的结构体: net_device:用于描述网络设备的属性,为上层提供一个统一的操作接口.网络设备的驱动实际上就是填充此结构体,实现其中的各种 ...
- virtual box 中两个虚拟机 、宿主机 三机互通并且能上外网设置
virtual box 中两个虚拟机 .宿主机 三机互通并且能上外网设置 1:背景:因为需要学习linux,所以需要在虚拟机里装linux系统,测试要么宿主机与虚拟机linux网络实验测试:要么另一台 ...
- Android IOS WebRTC 音视频开发总结(六)-- iOS开发之含泪经验
前段时间在搞webrtc iOS开发,所以将标题改为了Android IOS WebRTC 音视频开发总结, 下面都是开发过程中的经验总结,转载请说明出处(博客园RTC.Blacker): 1. IO ...
- Jquery获取selelct选中值
误区: 一直以为jquery获取select中option被选中的文本值,是这样写的: $("#s").text(); //获取所有option的文本值 实际上应该这样: $(& ...
- Android中SearchView修改字体颜色
首先获取searchView控件,比如在actionbar上获取: SearchView searchView = (SearchView) menu.findItem(R.id.action_sea ...
- 视频特效制作:如何给视频添加边框、水印、动画以及3D效果
2014-12-08 09:47 编辑: suiling 分类:iOS开发 来源:叶孤城的blog 招聘信息: iOS手机软件开发工程师 iOS工程师 Web后端高级开发工程师 iOS软件工程师 ja ...