You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by Apache Wiki <wi...@apache.org> on 2007/10/11 05:19:57 UTC
[Lucene-hadoop Wiki] Update of "Hbase/HbaseShell/HQL" by udanax
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Lucene-hadoop Wiki" for change notification.
The following page has been changed by udanax:
http://wiki.apache.org/lucene-hadoop/Hbase/HbaseShell/HQL
The comment on the change is:
It's added to hbase shell page. and un-implemented features moved to ShellPlans.
------------------------------------------------------------------------------
- [[TableOfContents(4)]]
+ deleted
- ----
- == Hbase Query Language (HQL) ==
- HQL is an SQL-like query language for Hbase. You can use it to query and modify tables in Hbase.
- HQL is not intended to fully support the SQL syntax and semantics.
- HQL, instead, is developed to help easy manipulation of tables in Hbase through the Hbase Shell command line without using programming APIs.
-
- We borrowed the syntax definition style from MySQL.
-
- The issue [https://issues.apache.org/jira/browse/HADOOP-1720 HADOOP-1720] is adding HQL support to the Hbase Shell.
-
- ''Thanks to Edward Yoon for his initial idea of HQL, and to Stack for his suggestions. Any suggestions for HQL in this wiki page, or to [[MailTo(icsong AT SPAMFREE gmail DOT com)]]''
-
- == Data Definition Statements ==
- === CREATE TABLE Syntax ===
- {{{
- CREATE TABLE table_name (
- column_family_spec
- [, column_family_spec]
- ...
- )
-
- colum_family_spec:
- column_family_name
- [MAX_VERSIONS=n]
- [MAX_LENGTH=n]
- [COMPRESSION=NONE|BLOCK|RECORD]
- [IN_MEMORY]
- [BLOOMFILTER=NONE|BLOOM|COUNTING|RETOUCHED VECTOR_SIZE=n NUM_HASH=n]
- }}}
-
- CREATE TABLE enables you to create a new table with various options for each column family.
-
- * MAX_VERSIONS makes a table keep only the recent n versions in a cell. Its default value is 3, i.e., only the most recent 3 versions of values are stored in a cell.
-
- * MAX_LENGTH specifies the maximum size of a column value. By default, the maximum size is unlimited. It is limited only by Integer.MAX_VALUE.
-
- * COMPRESSION specifies which compression technique to use for the column family. By default, Hbase does not compress any data.
-
- * IN_MEMORY specifies whether to keep the values in the column family in-memory, or not. By default, values are not kept in-memory.
-
- * BLOOMFILTER specifies which bloom filter to use for the column family. By default, none of the bloom filters is used. You can specify the options in two ways: with VECTOR_SIZE and NUM_HASH, or with NUM_ENTRIES. VECTOR_SIZE specifies the number of elements in the vector, and NUM_HASH specifies the number of hash functions to use; With NUM_ENTRIES, you specify only the approximated number of entries in the column, and VECTOR_SIZE and NUM_HASH are automatically determined. Currently, the NUM_ENTRIES option is not supported.
-
- * See [http://lucene.zones.apache.org:8080/hudson/job/Hadoop-Nightly/javadoc/org/apache/hadoop/hbase/HColumnDescriptor.html HColumnDescriptor API] for more information.
-
- === DROP TABLE Syntax ===
- {{{
- DROP TABLE table_name [, table_name] ...
- }}}
-
- DROP TABLE removes one or more tables.
-
- === ALTER TABLE Syntax ===
- {{{
- ALTER TABLE table_name
- alter_spec [, alter_spec] ...
-
- alter_spec:
- ADD column_family_spec
- | ADD (column_family_spec, ...)
- | DROP column_family_name
- | CHANGE column_family_name column_family_spec
- }}}
-
- ALTER TABLE changes the structure of the specified table. You can
- add, delete, or change column families.
-
- == Data Manipulation Statements ==
- === SELECT Syntax ===
- {{{
- SELECT { column_name [, column_name] ... | * }
- FROM table_name
- [WHERE row = 'row-key' | STARTING FROM 'row-key']
- [NUM_VERSIONS = version_count]
- [TIMESTAMP 'timestamp']
- [LIMIT = row_count]
- [INTO FILE 'file_name']
-
- column_name:
- column_family_name
- | column_family_name:column_label_name
- }}}
-
- SELECT retrieves a subset of data from the specified table.
-
- * A column_name with spaces in it should be single-quoted.
-
- * STARTING FROM returns all the rows starting from 'row-key'.
-
- * NUM_VERSIONS retrieves only the recent n versions of values in a cell.
-
- * TIMESTAMP returns only the values with the specified timestamp.
-
- * LIMIT limits the number of rows to be returned.
-
- * INTO FILE outputs the returned rows into the specified file. For SELECT INTO another table, see INSERT INTO SELECT below.
-
- === INSERT Syntax ===
- {{{
- INSERT INTO table_name (colmn_name, ...)
- VALUES ('value', ...)
- WHERE row = 'row-key'
- [TIMESTAMP 'timestamp']
- }}}
-
- INSERT inserts a set of values into a table.
-
- * If the specified column already exists, the new value is stored as a new version.
-
- * If TIMESTAMP is not specified for the value, the current time is used as its timestamp.
-
- {{{
- INSERT INTO table_name (colmn_name, ...)
- [TIMESTAMP 'timestamp']
- SELECT ...
- }}}
-
- * TIMESTAMP inserts the rows selected by SELECT ... with the specified timestamp
-
- === DELETE Syntax ===
- {{{
- DELETE { column_name, [, column_name] ... | *}
- FROM table_name
- WHERE row = 'row-key'
- }}}
-
- DELETE removes a subset of data from a table.
-
- === LOAD FROM FILE Syntax ===
- {{{
- LOAD FROM FILE 'file_name'
- INTO TABLE table_name
- }}}
-
- LOAD FROM FILE reads rows from the specified file and inserts these rows into the specified table. LOAD FROM FILE is complement of SELECT INTO FILE.
-
- === SOURCE Syntax ===
- {{{
- SOURCE 'file_name'
- }}}
-
- SOURCE reads HQL statements from the specified file and executes them.
-
- == Miscellaneous Statements ==
- {{{
- SHOW TABLES
- }}}
-
- SHOW TABLES shows all available tables, including disabled tables. For disabled tables,
- it shows that they are disabled.
-
- {{{
- DESCRIBE table_name
- }}}
-
- DESCRIBE shows the structure of the specified table such as the table's column families, compression technique being used, and so on.
-
- {{{
- ENABLE | DISABLE table_name
- }}}
-
- ENABLE (DISABLE) enables (disables) the specified table.
-
- == Transaction-Related Statements ==
- === START TRANSACTION, COMMIT, and ROLLBACK Syntax ===
- {{{
- START TRANSACTION ON 'row-key' OF table_name | BEGIN ON 'row-key' OF table_name
- COMMIT ['timestamp']
- ROLLBACK
- }}}
-
- You can group together a sequence of data manipulation statements in a single-row transaction.
-
- The START TRANSACTION and BEGIN statements begin a new single-row transaction under the specified 'row-key' of table_name.
-
- COMMIT commits the current transaction, making its changes permanent. If timestamp is specified on commit, all the modifications under the single-row transaction are stored with the specified timestamp. If not, they are stored with the current time as their timestamps.
-
- ROLLBACK rolls back the current transaction, canceling its changes.
-
- By default, for every statement execution that updates a table, Hbase immediately stores the update on disk.
-
- ''~- TRANSACTION on a row-level only -- and this is all you could guarantee in HBase -- may be a bit-over-the-top and require more effort than its worth. How about implementing this one last, if it is needed at all? -- St.Ack-~''
-