The document contains instructions for creating database tables, stored procedures, and triggers in PostgreSQL. It includes steps to:
1. Create a product table with fields and procedures to print the table contents, select a product by ID, and calculate the average price.
2. Create an account table and triggers.
3. Write PostgreSQL statements to create a countries table, duplicate it, rename it, add a primary key, insert records, insert NULL values, insert multiple records, and use SELECT statements to query the table.
The document contains instructions for creating database tables, stored procedures, and triggers in PostgreSQL. It includes steps to:
1. Create a product table with fields and procedures to print the table contents, select a product by ID, and calculate the average price.
2. Create an account table and triggers.
3. Write PostgreSQL statements to create a countries table, duplicate it, rename it, add a primary key, insert records, insert NULL values, insert multiple records, and use SELECT statements to query the table.
The document contains instructions for creating database tables, stored procedures, and triggers in PostgreSQL. It includes steps to:
1. Create a product table with fields and procedures to print the table contents, select a product by ID, and calculate the average price.
2. Create an account table and triggers.
3. Write PostgreSQL statements to create a countries table, duplicate it, rename it, add a primary key, insert records, insert NULL values, insert multiple records, and use SELECT statements to query the table.
The document contains instructions for creating database tables, stored procedures, and triggers in PostgreSQL. It includes steps to:
1. Create a product table with fields and procedures to print the table contents, select a product by ID, and calculate the average price.
2. Create an account table and triggers.
3. Write PostgreSQL statements to create a countries table, duplicate it, rename it, add a primary key, insert records, insert NULL values, insert multiple records, and use SELECT statements to query the table.
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;