Help Center/ GaussDB/ M-Compatibility Developer Guide(Centralized)/ Creating an M-compatible Database and User
Updated on 2025-10-23 GMT+08:00

Creating an M-compatible Database and User

An M-compatible database must be created in a non-M-compatible database. Ensure that the templatem template database exists in the current environment.

gaussdb=# \l
                              List of databases
   Name    | Owner | Encoding |   Collate   |    Ctype    | Access privileges 
-----------+-------+----------+-------------+-------------+-------------------
 postgres  | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
 template1 | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
 templatem | omm   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/omm           +
           |       |          |             |             | omm=CTc/omm
 (4 rows)

After the upgrade from a version earlier than 505.1.0 to the latest version, if the templatem template database is not created in the basic package, the templatem template database will not be created after the upgrade.

To use the M-compatible database, you need to create it by referring to the following example:

gaussdb=# CREATE DATABASE m_db dbcompatibility = 'M' template=templatem;
gaussdb=# \c m_db
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "m_db" as user "omm".
m_db=# CREATE USER omm_test password '********';
m_db=# GRANT ALL privileges to omm_test;

For details about other operations after an M-compatible database is created, see SQL Reference.

You are advised to check whether a non-M-compatible templatem database exists before the upgrade to 505.1. If the templatem database has been created, contact Huawei technical support. If you ignore it, features related to M-compatible databases are affected.