Friday 14 February 2020

Cassandra: expand on: Show the contents of table’s row vertically

The ‘expand on’ command shows the contents of a table row wise by expanding each column specifically.
cqlsh> SELECT * FROM cassandratutorial.employee;

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

(4 rows)

After executing ‘expand on’ command table content is displayed like below.
cqlsh> expand on;
Now Expanded output is enabled
cqlsh> 
cqlsh> SELECT * FROM cassandratutorial.employee;

@ Row 1
-----------+---------
 id        | 1
 age       | 30
 firstname | Krishna
 lastname  | Gurram

@ Row 2
-----------+---------
 id        | 2
 age       | 31
 firstname | Ram
 lastname  | Gurram

@ Row 3
-----------+---------
 id        | 4
 age       | 45
 firstname | Chitra
 lastname  | Rajan

@ Row 4
-----------+---------
 id        | 3
 age       | 45
 firstname | Vijay
 lastname  | Ponnam

(4 rows)

You can switch off this behaviour by executing the command ‘expand off’.

cqlsh> expand off
Disabled Expanded output.
cqlsh> 
cqlsh> SELECT * FROM cassandratutorial.employee;

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

(4 rows)


Previous                                                    Next                                                    Home

No comments:

Post a Comment