Help Center/ GaussDB(DWS)/ More Documents/ User Guide (Kuala Lumpur Region)/ FAQs/ Database Usage/ What Do I Do If Date Type Is Automatically Converted to the Timestamp Type During Table Creation?
Updated on 2023-03-17 GMT+08:00

What Do I Do If Date Type Is Automatically Converted to the Timestamp Type During Table Creation?

When creating a database, you can set the DBCOMPATIBILITY parameter to the compatible database type. The value of DBCOMPATIBILITY can be ORA, TD, and MySQL, indicating Oracle, Teradata, and MySQL databases, respectively. If this parameter is not specified during database creation, the default value ORA is used. In ORA compatibility mode, the date type is automatically converted to timestamp(0).

To avoid such conversion, set the database to the MySQL compatibility mode, which is the only mode that supports the date type. The compatibility mode can be configured only during database creation. GaussDB(DWS) supports the MySQL compatibility mode in cluster version 8.1.1 and later. To configure this mode, run the following commands:

1
2
3
4
5
6
7
8
9
gaussdb=> CREATE DATABASE mydatabase DBCOMPATIBILITY='mysql';
CREATE DATABASE
gaussdb=> \c mydatabase
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "mydatabase" as user "dbadmin".
mydatabase=> create table t1(c1 int, c2 date);
NOTICE: The 'DISTRIBUTE BY' clause is not specified. Using round-robin as the distribution mode by default.
HINT: Please use 'DISTRIBUTE BY' clause to specify suitable data distribution column.
CREATE TABLE