![]() The “ schema_name” is the schema to be altered while “ new_name” represents the new/modified name of the schema. To do so, follow the below syntax: ALTER SCHEMA schema_name In PostgreSQL, the ALTER SCHEMA statement is used along with the RENAME TO clause to modify the schema’s name. How to Rename a Schema Using ALTER SCHEMA Statement in Postgres? The output authenticates the working of the ALTER SCHEMA statement. The output shows that the schema owner has been successfully changed from “ postgres” to “ command_prompt”.Īlternatively, you can verify the schema’s owner via the following command: SELECT * FROM pg_catalog.pg_namespace Let’s run the “\dn” command to verify the working of “ ALTER TABLE” and “ OWNER TO” statements: \dn The “ ALTER SCHEMA” message in the output proves that the selected schema has been altered successfully. To do so, we will execute the following command: ALTER SCHEMA employee_details1 OWNER TO command_prompt Suppose we want to change the owner of the “ employee_details1” schema from “ postgres” to “ command_prompt”. Let’s run the “\du” command to see the available users: \du Alternatively, you can run the below command to check the schema’s owner: SELECT * FROM pg_catalog.pg_namespace Output shows the schema's names and their owners. Run the “\dn” command to get the list of available schemas: \dn Hit the “enter” button to proceed further. The below-listed steps will help you understand the working of ALTER SCHEMA statement:įirstly, open the SQL Shell(psql) and provide the necessary details like user name, password, etc.: In the above syntax, the “ schema_name” represents the schema to be altered while “ new_owner” represents the name of the new owner. In PostgreSQL, the ALTER SCHEMA statement is used with the collaboration of the OWNER TO clause to change the schema’s owner. How to Change Schema’s Owner Using ALTER SCHEMA Statement in Postgres? ![]() This write-up will teach you how to change the schema’s owner and how to rename a schema in PostgreSQL using the ALTER SCHEMA statement. In order to modify the schema’s definition, you must own that schema. PostgreSQL offers an “ ALTER SCHEMA” statement that is used to modify the schema’s definition, such as altering the schema’s owner, renaming a schema, and so on.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |