Postgresql Ex 8

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Exercise 6: Create Product Table and Procedures

Date: 31/07/23

1. Create a product database with appropriate fields and


-Create procedure to print the entire content of the table.
-Write procedure to select products value according to the
productID.
-Calculate the average price

STEPS:
 Create a database and table containing product database with
fields
 Insert values for the table

 Procedure to call the table and print the table


 Procedure to select product value according to the product ID

 Procedure to calculate average price


Exercise 7: Creating an account table and Triggers
Date: 10/08/23
Exercise 8: PostgreSQL Commands
Date: 04/09/23

1. Write an postgresql statement to create a table named countries


including columns country_id, country_name, and region_id and
make sure that no countries except Italy, China, India will be
entered

2. Write a postgresql statement to create a duplicate copy of


countries table including structure and data by name
dup_countries.
3. Write a postgresql statement to rename the table countries to
country_new.

4. Write a postgresql statement to add a primary key for a


combination of columns region_id and country_id.

5. Write a postgresql statement to insert a record with your


own value into the table countries against each column.
6. Write a postgresql statement to insert NULL values into the
region_id column for a row of countries table.

7. Write a postgresql statement to insert 3 rows by a single insert


statement.

8. Apply diIerent combinations of select statement to the


countries table and capture the results

SELECT c_name FROM countries;


SELECT * FROM countries WHERE region_id = ‘2’;

SELECT * FROM countries ORDER BY country_name ASC;

SELECT * FROM countries LIMIT 2;

You might also like