Saturday, August 11, 2012

Create table in PostgreSQL.

In this Section we are going to learn that how are tables created in PostgreSQL.

First of all you need the PostgreSQL software installed on your computer. If you don't have no problem you can download from the following link. Choose your platform and you are ready to download.

Download :  PostgreSQL

OK after you download and install the software then run it from the command prompt as mentioned in the read me manual.

A screen will appear in front of you when you run the program by filling in the appropriate login or authentication information.

Then simple write the following lines on the screen and run it.

Type the two paragraphs A) and B) on your screen and run it.

A) Item Table

     create table item
      (item_no integer primary key,
      item_name text,
      qty float);

B) Supplier table.

     create table supplier
     (supp_no integer primary key,
     supp_name text,
     address text,
     city text,
     phoneno integer);

When you run these two codes in your command prompt two tables named Item  and Supplier will be created in your database.

Now we will insert data in these two tables. now Run the Following statements on your command prompt and data will be inserted in both tables.

C) Inserting Data in Item Table.

     insert into item values(1,'cdrom',1200);
     insert into item values(2,'cd writer',1500);
     insert into item values(3,'fdd',800);
     insert into item values(4,'hdd',3200);
     insert into item values(5,'speaker',1200);
     insert into item values(6,'usb',500);
     insert into item values(7,'mouse',500);
     insert into item values(8,'monitor',1200);





D) Inserting Data in Supplier table.


     insert into supplier values(1,'singh0','ozar0','nasik0',5602077);
     insert into supplier values(2,'singh1','ozar1','nasik1',5602076);
     insert into supplier values(3,'singh2','ozar2','nasik2',5602075);
     insert into supplier values(4,'singh3','ozar3','nasik3',5602074);
     insert into supplier values(5,'singh4','ozar4','nasik4',5602073);
     insert into supplier values(6,'singh5','ozar5','nasik5',5602072);
     insert into supplier values(7,'singh6','ozar6','nasik6',5602071);
     insert into supplier values(8,'singh7','ozar7','nasik7',5602070);*/
     insert into supplier values(9,'singh8','ozar8','nasik0',2775411);





No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...