Posts

Showing posts from May, 2015

How to get to get column name,datatype & length etc of a table.

Image
select column_name , data_type ,character_maximum_length from INFORMATION_SCHEMA.COLUMNS where table_name = 'donor_visit_details'; select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'donor_visit_details';

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