Use the ALTER DATABASE command to change properties of a database; for example, the default character set, the name, the default schema, the owner of the database, or whether history data is to be collected for the database.
ALTER DATABASE <db_name> [ OWNER TO <user> ] [ RENAME TO <new_db_name> ]
[ SET DEFAULT SCHEMA <schema_name> ] [ SET DEFAULT CHARACTER SET LATIN9 ] ]
[ COLLECT HISTORY {ON|OFF|DEFAULT} ]
| Input | Description |
|---|---|
| <db_name> | The name of the database. |
| OWNER TO | The name of the new database owner. |
| RENAME TO | The new database name. |
| SET DEFAULT SCHEMA | The default schema for users who connect to the database. If you change the default schema, users who inherited access to the previous default schema lose access to that schema and inherit access to the new schema. There users no longer have access to the previous default schema unless they were explicitly granted access to it. |
| SET DEFAULT CHARACTER SET | If you upgraded before IBM® Netezza® release 2.2, the default character set is set to UNDECLARED. Set the default character set to LATIN9 to be able to compare, join, or cast char or nchar class data. |
| COLLECT HISTORY | Whether history data is to be collected for
sessions attached to this database.
|
| Output | Description |
|---|---|
| ALTER DATABASE | The command completed successfully. |
| ERROR: ALTER DATABASE: database "db1" is being accessed by other users | The database is being used by other users. |
You must be the admin user, the database owner, or your account must have the Alter privilege for the database or for the Database object class. To change the database owner or the default schema, you must have List privilege for that user or schema.
MYDB.SCH1(USER)=> ALTER DATABASE emp SET DEFAULT
CHARACTER SET LATIN9;
MYDB.SCH1(USER)=> ALTER DATABASE emp OWNER TO admin3;
MYDB.SCH1(USER)=> ALTER DATABASE emp RENAME TO employees;