Important Query for PostgreSQL

Get All the Data of Table
Select * from table_name;

get the number of rows present table.
Select count(*) from table_name;

get dat of perticular column
Select column_name from table_name;


update data

update table_name  set location_id = 10
# here whole location_id column will contain 10.

if u want to update for specific row
update table_name set mark = 100 where id = 1

Delete Data

delete from table_name where id = 3  ---- one row
delete from table_name where id in (3,6,7,8,9,11,12,13,16,17,18)  ---- multiple row
alter table donor_visit_details_kgtemp  drop column weight --delete one column


ALTER SEQUENCE table_name_id_seq RESTART with 107
# By this next ID will generate from 107 to onwards irrespecting of ID present

Comments

  1. It is nice blog Thank you porovide importent information and i am searching for same information to save my time
    Ruby on Rails Online Course Bangalore

    ReplyDelete

Post a Comment