Postgres commands


1. Access postgresSQL.

->su postgres

2. Create user.

->CREATE USER username

3. Delete user.

-> DROP USER username

4. Create user can create DATABASE/

->CREATE USER manuel WITH PASSWORD ‘jw8s0F4’ CREATEDB;

5. List all user.

->\du

6.This lists databases:

->SELECT datname FROM pg_database;

->\list

7.This lists tables in the current database

->SELECT table_schema,table_name FROM information_schema.tables ORDER BY table_schema,table_name;

->\dt

8.Select particular database with specific user.

-> psql databaseName userName;

->psql databaseName

->\c databaseName

9. List info about current database connection.

->\conninfo

10.List database list.

->\dg

11. List all user.

->\du

12.Quits the psql program

->\q

13.To exit from psql command line utilities.
->\q type and press enter
14. Describe table like mysql.
>\d+ tablename
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s