Psostgress SQL

 1 To create database
    create database database_name;

2 To show all the database
    show databases;

3 To use/select the database
    use database_name;

4 to show the available tables
    show tables;

5 to create the table
    create table table_name( the columns with their type);
    Eg:
    create table coffee_table(id int , name varchar(250) , country varchar(250) );

6 To show the contents in the table
    descirbe table_name;

7 To add contents to the table
    insert into table_name values (1 , "Ram" , "USA" );

8 To select all the data from the table
    select * from table_name;

9 To select specific parameters/columns from table
    select column_name from table_name;
    Eg:
    select name from coffee_table;

10 To select/display specific data with certain values from table
    select * from table_name where column = "value";
    Eg:
    select * from coffee_table where country ="Nepal";

11 To select/display specific data with two or more certain values from table
    
select * from table_name where column = "value" or  column = "value";
    Eg:
    select * from coffee_table where country ="Nepal" or name="Ram";

12 To select specific column with select/display specific data with two or more certain values 
    Eg:
    select name from coffee_table where country="USA" or name="Ram";

13 To delete a certain value from table
    Eg:
    delete from coffee_table where name="Ram";

14 To update the data of certain values
    Eg:
    update coffee_table set country="Nepal" where name="Ram";

15 sort the order of the table in ascending order
    Eg:
    select * from coffee_table order by id asc;

16 Sort the order of the table in ascending order
    Eg:
    select * from coffee_table order by id desc;

17 To add extra column in the table
    Eg:
    alter table coffee_table add type string;








Comments

Popular posts from this blog

Introduction to Node Js

Express res.send