3. Getting Started With Hive Beeline - 图1

Getting Started With Hive Beeline

Getting Beeline

  1. $ bin/beeline --help
  2. Usage: java org.apache.hive.cli.beeline.BeeLine
  3. -u <database url> the JDBC URL to connect to
  4. -r reconnect to last saved connect url (in conjunction with !save)
  5. -n <username> the username to connect as
  6. -p <password> the password to connect as
  7. -d <driver class> the driver class to use
  8. -i <init file> script file for initialization
  9. -e <query> query that should be executed
  10. -f <exec file> script file that should be executed
  11. -w (or) --password-file <password file> the password file to read password from
  12. --hiveconf property=value Use value for given property
  13. --hivevar name=value hive variable name and value
  14. This is Hive specific settings in which variables
  15. can be set at session level and referenced in Hive
  16. commands or queries.
  17. --property-file=<property-file> the file to read connection properties (url, driver, user, password) from
  18. --color=[true/false] control whether color is used for display
  19. --showHeader=[true/false] show column names in query results
  20. --headerInterval=ROWS; the interval between which heades are displayed
  21. --fastConnect=[true/false] skip building table/column list for tab-completion
  22. --autoCommit=[true/false] enable/disable automatic transaction commit
  23. --verbose=[true/false] show verbose error messages and debug info
  24. --showWarnings=[true/false] display connection warnings
  25. --showDbInPrompt=[true/false] display the current database name in the prompt
  26. --showNestedErrs=[true/false] display nested errors
  27. --numberFormat=[pattern] format numbers using DecimalFormat pattern
  28. --force=[true/false] continue running script even after errors
  29. --maxWidth=MAXWIDTH the maximum width of the terminal
  30. --maxColumnWidth=MAXCOLWIDTH the maximum width to use when displaying columns
  31. --silent=[true/false] be more silent
  32. --autosave=[true/false] automatically save preferences
  33. --outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv] format mode for result display
  34. Note that csv, and tsv are deprecated - use csv2, tsv2 instead
  35. --incremental=[true/false] Defaults to false. When set to false, the entire result set
  36. is fetched and buffered before being displayed, yielding optimal
  37. display column sizing. When set to true, result rows are displayed
  38. immediately as they are fetched, yielding lower latency and
  39. memory usage at the price of extra display column padding.
  40. Setting --incremental=true is recommended if you encounter an OutOfMemory
  41. on the client side (due to the fetched result set size being large).
  42. Only applicable if --outputformat=table.
  43. --incrementalBufferRows=NUMROWS the number of rows to buffer when printing rows on stdout,
  44. defaults to 1000; only applicable if --incremental=true
  45. and --outputformat=table
  46. --truncateTable=[true/false] truncate table column when it exceeds length
  47. --delimiterForDSV=DELIMITER specify the delimiter for delimiter-separated values output format (default: |)
  48. --isolation=LEVEL set the transaction isolation level
  49. --nullemptystring=[true/false] set to true to get historic behavior of printing null as empty string
  50. --maxHistoryRows=MAXHISTORYROWS The maximum number of rows to store beeline history.
  51. --help display this message
  52. Example:
  53. 1. Connect using simple authentication to HiveServer2 on localhost:10000
  54. $ beeline -u jdbc:hive2://localhost:10000 username password
  55. 2. Connect using simple authentication to HiveServer2 on hs.local:10000 using -n for username and -p for password
  56. $ beeline -n username -p password -u jdbc:hive2://hs2.local:10012
  57. 3. Connect using Kerberos authentication with hive/localhost@mydomain.com as HiveServer2 principal
  58. $ beeline -u "jdbc:hive2://hs2.local:10013/default;principal=hive/localhost@mydomain.com"
  59. 4. Connect using SSL connection to HiveServer2 on localhost at 10000
  60. $ beeline "jdbc:hive2://localhost:10000/default;ssl=true;sslTrustStore=/usr/local/truststore;trustStorePassword=mytruststorepassword"
  61. 5. Connect using LDAP authentication
  62. $ beeline -u jdbc:hive2://hs2.local:10013/default <ldap-username> <ldap-password>