This topic describes how to use Phoenix to query data.


The runtime environment for Phoenix is prepared. For more information about how to prepare the environment, see Prepare an environment.

Quick start

  1. Execute the following statement to create a table named us_population:
    CREATE TABLE IF NOT EXISTS us_population (
       state CHAR(2) NOT NULL,
       city VARCHAR NOT NULL,
       population BIGINT
       CONSTRAINT my_pk PRIMARY KEY (state, city));
  2. Execute the following statements to write data:
    UPSERT INTO us_population VALUES('NY','New York',8143197);
    UPSERT INTO us_population VALUES('CA','Los Angeles',3844829);
    UPSERT INTO us_population VALUES('IL','Chicago',2842518);
    UPSERT INTO us_population VALUES('TX','Houston',2016582);
    UPSERT INTO us_population VALUES('PA','Philadelphia',1463281);
    UPSERT INTO us_population VALUES('AZ','Phoenix',1461575);
    UPSERT INTO us_population VALUES('TX','San Antonio',1256509);
    UPSERT INTO us_population VALUES('CA','San Diego',1255540);
    UPSERT INTO us_population VALUES('TX','Dallas',1213825);
    UPSERT INTO us_population VALUES('CA','San Jose',912332);
  3. Run an SQL query.
    SELECT state as "State",count(city) as "City Count",sum(population) as "Population Sum"
    FROM us_population
    GROUP BY state
    ORDER BY sum(population) DESC;
  4. Verify the result.
    Verify the result

Use the API to connect to Phoenix JDBC

  • Phoenix 5.x SDK maven dependency
  • Phoenix 4.x SDK maven dependency
        <version>${See release notes for the latest version in FAQ}</version>


For code examples, see Examples.