Performing DML Operations On PostgreSQL Tables

Share via:

In PostgreSQL, “ALTER” and “UPDATE” are two different SQL commands used to modify data in a database.
“ALTER” is used to modify the structure of the database, while “UPDATE” is used to modify the data stored within the database.
Update:
The UPDATE command plays a crucial role in modifying and updating data within PostgreSQL tables.

Views:
They are particularly useful for creating reusable query components and presenting data in a more convenient format.

View can be DROPPED by using following command.

Temporary Table:
Temporary tables provide a way to store and manipulate data within a session or a transaction.

A Temporary table is created in college database as student1.
Let’s exit and reconnect to the database to verify still the table exists.

Temporary tables are only visible to the session that creates them and   are automatically dropped at the end of the session or transaction.
Column Alias:
Column aliases provide a way to assign alternative names to the columns returned in a query result.

Schema:
A schema in PostgreSQL is a named container that holds a collection of database objects, such as tables, views, Indexes, functions, and more. It acts as a logical unit that helps organize and categorize these objects within a database.

When you create a table without specifying a schema, it is automatically created in the public schema. It is accessible to all users by default.

Table Space:

Creating a Tablespace:

To create a tablespace named “my_tablespace” at the location ‘C:\pg_tbsp2’, you Can use the following SQL command:

To list the tablespaces in that database use command: ‘\db’.
pg.default – The “pg.default” tablespace is the default location where user data is stored. When no tablespace is created.
pg.global  – It contains system catalogs that are shared among multiple databases, such as system tables and Indexes.
Creating a Table in the Tablespace:
To create a table named “my_table” within the “my_tablespace” tablespace. Run the following command:

If you want to move the “my table” table to a different tablespace, you can use the “ALTER TABLE” statement.
ALTER TABLE my_table SET TABLESPACE new_tablespace;

 

Author    : Prudhvi Teja

LinkedIn  : http://linkedin.com/in/prudhvi-teja-nagabhyru-715052224

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTExperts is always active on social media platforms.

Facebook  : https://www.facebook.com/ktexperts/
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment