8/28/2023 0 Comments Postgresql rename![]() I was hoping there was some way to "add a name" to a table or column, so that old_name and new_name will both work, and then at a later time remove the old name. If existing clients are using the old name, you can't just yank it out from under them. PostgreSQL lets you rename tables and columns via alter table, but often this isn't feasible in a production without significant downtime. ![]() Sometimes one name is used in developing a feature, but testing with real users reveals that a better name is needed, and it'd be nice to have the names for things in the DB match the names used in the UI. ![]() Maybe requirements shifted slightly, or maybe as time went on, a better understanding of the concept being represented developed. ![]() See SET and Chapter 20 for more information about allowed parameter names and values.It often happens that the original name something is given is not the best name. SET FROM CURRENT saves the session's current value of the parameter as the database-specific value. Use RESET ALL to clear all database-specific settings. If value is DEFAULT or, equivalently, RESET is used, the database-specific setting is removed, so the system-wide default setting will be inherited in new sessions. Set this database's session default for the specified configuration parameter to the given value. This form of the command cannot be executed inside a transaction block. The new default tablespace of the database. If true, then this database can be cloned by any user with CREATEDB privileges if false, then only superusers or the owner of the database can clone it. How many concurrent connections can be made to this database. If false then no one can connect to this database. The name of the database whose attributes are to be altered. Certain variables cannot be set this way, or can only be set by a superuser. Only the database owner or a superuser can change the session defaults for a database. The database-specific default overrides whatever setting is present in nf or has been received from the postgres command line. Whenever a new session is subsequently started in that database, the specified value becomes the session default value. The remaining forms change the session default for a run-time configuration variable for a PostgreSQL database. Tables and indexes in non-default tablespaces are unaffected. The new default tablespace must be empty for this database, and no one can be connected to the database. This command physically moves any tables or indexes in the database's old default tablespace to the new tablespace. ![]() Only the database owner or a superuser can do this you must also have create privilege for the new tablespace. The fourth form changes the default tablespace of the database. (Note that superusers have all these privileges automatically.) To alter the owner, you must own the database and also be a direct or indirect member of the new owning role, and you must have the CREATEDB privilege. The third form changes the owner of the database. (Connect to a different database if you need to do that.) Only the database owner or a superuser can rename a database non-superuser owners must also have the CREATEDB privilege. The second form changes the name of the database. (See below for details.) Only the database owner or a superuser can change these settings. The first form changes certain per-database settings. ALTER DATABASE changes the attributes of a database. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |