PostgreSQL – Rename Schema

You can rename a schema using the ALTER SCHEMA statement. Here’s the basic syntax for renaming a schema: ALTER SCHEMA old_schema_name RENAME TO new_schema_name; Replace old_schema_name with the current name of the schema you want to rename, and new_schema_name with the new name you want to assign to the schema. Here’s an example: ALTER SCHEMA…

PostgreSQL -Create Schema

You can create a new schema using the CREATE SCHEMA statement. A schema is a namespace that can contain tables, views, functions, and other database objects. Here’s the basic syntax for creating a schema: CREATE SCHEMA schema_name; Replace schema_name with the name you want to give to your new schema. Here’s a complete example: CREATE…

PostgreSQL – ROLLBACK PREPARED

The ROLLBACK PREPARED command is used to roll back a prepared transaction in PostgreSQL database. Prepared transactions are a feature that allows you to prepare a transaction for execution and then later commit or roll back that transaction using a unique identifier known as the transaction’s name or identifier. Here’s the syntax for the ROLLBACK…

PostgreSQL – ROLLBACK Statement

The ROLLBACK statement is used to undo all changes made within the current transaction and discard those changes. It effectively cancels the transaction and restores the database to its state before the transaction began. Here’s how you typically use the ROLLBACK statement in PostgreSQL: Start a transaction using the BEGIN statement: BEGIN; This begins a…

PostgreSQL – COMMIT Statement

The COMMIT statement is used to permanently save any changes made within a transaction to the PostgreSQL database. PostgreSQL, like many other relational database management systems, uses transactions to group a series of database operations into a single unit of work. The COMMIT statement is issued to confirm that the changes made within a transaction…

PostgreSQL – RPAD Function

The rpad function in PostgreSQL database is used to right-pad a string with a specified character or a set of characters until the resulting string reaches a specified length. This function is often used to format strings to a fixed width. Here’s the syntax for the rpad function: rpad(input_string, length, pad_string) The rpad function takes…