Saturday 1 February 2020

Cassandra: Aliases in SELECT statements


CQL support aliases in SELECT statement using AS keyword.

Example
cqlsh> SELECT * FROM cassandratutorial.employee;

 id | age | firstname | lastname
----+-----+-----------+----------
  1 |  30 |   Krishna |   Gurram
  2 |  31 |       Ram |   Gurram
  3 |  45 |     Vijay |   Ponnam

(3 rows)

You specify column name aliases using AS clause like below.

SELECT id AS empId, firstname as empName FROM cassandratutorial.employee;


In the above example, empId is an alias for id, empName is an alias for firstName.
cqlsh> SELECT id AS empId, firstname as empName FROM cassandratutorial.employee;

 empid | empname
-------+---------
     1 | Krishna
     2 |     Ram
     3 |   Vijay

(3 rows)


Previous                                                    Next                                                    Home

No comments:

Post a Comment