

#Postgresql rename how to
How to Rename a Database in PostgreSQL using various methods? This parameter is also important to alter the database statement to change the database name. New database name –This is defined as the new database name, which we have changed using the alter database command.
We have used rename to keyword with alter database statement in PostgreSQL. Rename To –This keyword is defined as using this keyword, we can change the database name with a different name in PostgreSQL.

Old database name –This is defined as an old database name from the database server, which we have renamed to a different name.We can also use the alter database statement to change the feature of the database. Alter database –We use the alter database statement to rename the database with a different name.Alter database old_database_name (Name of database which was we have change to different name.) RENAME TO new_database_name (New name of database which was we have changing.)īelow is the parameter description syntax of the renamed database In Postgres 9.Hadoop, Data Science, Statistics & othersīelow is the syntax of the renamed database in PostgreSQL. ALTER TABLE example2 RENAME example1fk TO example3fk - rename column But the column name will likely have to change in your example, too. No reference to the referenced table name. However, since you did not specify a constraint name at creation time, the system picked a default, which is example2_example1fk_fkey in your case unless the name was taken. You can ignore that, or you may want to rename the constraint so it's not misleading. The name of the constraint remains unchanged. Changing table names will not impair functionality at all. Internally, every object is stored in a catalog table and the OID (internal primary key) of the object is used for everything else.Īccordingly, a FOREIGN KEY reference is stored in the catalog tables pg_constraint (the constraint itself incl. Internal dependencies between tables and / or other objects are never bound to the object name.
