alter database test owner to postgres īy using the list metacommand again, we can see that our database owner has now been changed. For this example, let's transfer test to postgres. To transfer ownership to another user, we pass the "owner to" option to alter database, following up with the name of the user we're transferring to. A different template can be specified by writing TEMPLATE name. By default, the new database will be created by cloning the standard system database template1. To create a database, you must be a superuser or have the special CREATEDB privilege. We can see with the list metacommand that the current owner of our test database is my user. Description CREATE DATABASE creates a new PostgreSQL database. select datname, datistemplate from pg_database įinally, let's use the alter database command to transfer ownership of our database. We can then check that our database has been updated by querying the pg_database table again. Creating PostgreSQL users At the command line, type the following command as the servers root user: You can now run commands as the PostgreSQL superuser. This time, we use the "is_template" option. In the same manner as connections, we can also manage whether or not our database is a template with alter database. select datname, datconnlimit from pg_database We can also check that our connection limit was updated by looking at the pg_database table. We can use the connect metacommand again to see that connections have been reenabled for our database. alter database test allow_connections true connection limit 1 To allow connections, but set a limit to the number of connections for our database, we use alter database again, this time with two options: allow connections, and connection limit. To see that our database is no longer accepting connections, we can try connecting to it using the connect metacommand. alter database test allow_connections false To do this, we use "alter database" with our database name, followed by "allow_connections false". First, let's try to remove connection privileges to our test database. ALLOW_CONNECTIONS and CONNECTION LIMITĪnother thing we can do with alter database is change our connection settings. postgres CREATE DATABASE moodle WITH OWNER moodleuser Character set and collation If the PostgreSQL servers default collation does not suit your needs, you can provide explicit LCCTYPE (character classification) and LCCOLLATE (string sort order) setting for your Moodle database. Use the list metacommand, we can see that example has now been renamed to test. This option is then followed by the new name for our database. To rename a database, we use "alter database" followed by the database name we're wanting to change, and then the "rename to" option. This command has a number of options for making changes to our databases. To make changes to our new database, we can use the "alter database" command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |