Skip to content
Ivan Krutov edited this page Jan 22, 2017 · 9 revisions

Perspective Shell has built-in SQL support. Currently only SELECT and EXPLAIN queries work. To execute SQL query just type it and press Enter:

perspective>select * from instances where name like '%test-vm%';

You may also want to execute queries in batch mode:

$ PERSPECTIVE_API_URL='http://api.example.com/' perspective --query 'select * from flavors where vcpus > 2'

To see a list of available tables type:

perspective>select tables();

To list available columns of a table type:

perspective>select columns('table_name');

Supported SQL features

  • Inner and outer joins (ON and USING clauses)
  • WHERE clause
  • ORDER BY clause
  • GROUP BY clause
  • HAVING clause
  • LIMIT clause
  • Functions

You may want to take a look at the SQL grammar file.

Built-in functions

SQL engine has a lot of built-in functions. To see full list type in shell:

perspective>select functions();

To view help for concrete function type:

perspective>selection functions('abs');

EXPLAIN clause

So far as SQL engine uses query planner to accelerate query processing you may want to know how the query is actually done. Use EXPLAIN statement to get a list of executed tasks:

perspective>explain select name from instances order by name;