Tuesday 31 January 2017

Postgresql ,Basic steps in Ubuntu by usingTerminal

1) To open  in Terminal
   $sudo -I (i) -u postgres psql

2)To check the database available
postgres=#\l

3)To create  database
      postgres=#create database manju;
           ( manju is db name).

4)To connect the db.
     postgres=#\c manju;

5)Creating Schema.
    postgres=#create schema publicschema;

6)To check the DataType
  postgres=#/d

7)create Table.
   postgres=#table publicschema.table1(id integer, password CHAR(10));

8)To check the catalog.
    postgres=#select* from pg_catalog.pg_tables;
 
     postgres=# select * from pg_catalog.pg_tables where schema!= 'information_schema' and schema name!='pg_catalog';


9)Insert values
     postgres=# into public.manju(1,'1');

9)To view the table
   postgres=#select * from public.manju;

10)To Truncate .
     postgres=#truncate public.manju;  
 
11)To Delete
      postgres=#delete from public.manju;

12)To Drop.
    postgres=#drop table public.manju;

2 comments: