HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

Compatible With MySQL Alias Support For Single Quotes

Availability

This feature is available since MogDB 5.0.0.

Introduction

Compatible support for MySQL aliases supports the syntax and functionality of single quotes (aliases for columns only).

Benefits

Enhance MogDB compatibility with MySQL to reduce application migration costs.

Description

Alias after AS supports single quotes (Name AS 'alias'), and supports Name followed directly by a single-quoted alias (Name 'alias').

Constraints

  • The BINARY keyword is not supported as a column name.
  • The a_expr qual_op syntax is not supported, i.e., the post operator

Syntax Description

  • {expression [ [ AS ] output_name ]} output_name Support for single-quote syntax
  • {expression [ output_name ]} output_name Support for single-quote syntax

Example

td_db=# SELECT a+1 AS 'quote1', b 'quote2' FROM test_quote;
  quote1  |  quote2
----------+----------
      2   |     2
      4   |     4
(2 rows)

td_db=# SELECT datetime '2023-6-1' 'name1';
      name1
---------------------
 2023-06-01 00:00:00
(1 row)

td_db=# SELECT date '2023-6-1' 'name1';
   name1
------------
 2023-06-01 
(1 row)

td_db=# SELECT a AS 'name1', b 'name2' FROM wxq;
  name1  |  name2
 --------+---------
       1 | yi
       2 | er
(2 rows)

td_db=# SELECT b+1 'quote2' FROM test_quote;
   quote2
------------
      3
      5
(2 rows)        
Copyright © 2011-2024 www.enmotech.com All rights reserved.