| tenant-type | | slug | obclient-interactive-commands-reference |
This topic provides a complete reference for all internal commands of the OBClient command-line client. These commands can be used in interactive OBClient sessions.
Command description
There are also some commands that can be run within the client. Note that all text commands must start at the beginning of a line and end with a semicolon (;).
Command list
Command |
Description |
|---|---|
?, \? |
helpis a synonym for . |
clear, \c |
Clears the current input statement. |
connect, \r |
Reconnect to the server. Optional parameters are db and host. |
conn |
connectis an alias for , which is compatible with Oracle SQL*Plus. |
delimiter, \d |
Sets the statement delimiter. |
edit, \e |
Use the $EDITOR editing command. |
ego, \G |
The command is sent to the OceanBase server, and the results are displayed vertically. |
exit, \q |
Exit obclient. Equivalent to quit. |
go, \g |
Send the command to the OceanBase server. |
help, \h |
Display this help. |
nopager, \n |
Disable pagination and print to stdout. |
notee, \t |
Do not write to the output file. |
pager, \P |
Set PAGER [to_pager]. Use PAGER to print query results. |
print, \p |
Prints the current command. |
prompt, \R |
Change your obclient prompt. |
quit, \q |
Exit obclient. |
rehash, # |
Rebuild and complete the hash. |
source, . |
Execute the SQL script file. Pass the file name as a parameter. |
status, \s |
Retrieves status information from the server. |
system, \! |
Execute system shell commands. This feature is available only on Unix-like systems. |
tee, \T |
Specify the output file [to_outfile]. All content will be appended to the specified output file. |
use, \u |
Use another database. Specify the database name as a parameter. |
charset, \C |
Switch to another character set. This may be required when processing binlogs of multibyte character sets. |
warnings, \W |
Warnings are displayed after each statement. |
nowarning, \w |
Warnings are not displayed after each statement. |
Examples of common commands
help, \h, ?
Displays help information:
obclient> help;
obclient> \h;
obclient> ?;
clear, \c
Clears the current input statement:
obclient> SELECT * FROM users
-> \c
obclient>
connect, \r, conn
Reconnects to the server:
obclient> connect;
obclient> \r;
obclient> conn testdb@localhost;
delimiter, \d
Sets the statement delimiter:
obclient> delimiter //
obclient> CREATE FUNCTION test() RETURNS INT
-> BEGIN
-> RETURN 1;
-> END
-> //
obclient> delimiter ;
ego, \G
Displays query results vertically:
obclient> SELECT * FROM users WHERE id = 1\G
*************************** 1. row ***************************
id: 1
name: Alice
email: alice@example.com
use, \u
Switches to another database:
obclient> use testdb;
obclient> \u testdb;
source, .
Execute an SQL script file:
obclient> source /path/to/script.sql;
obclient> . /path/to/script.sql;
status, \s
Display server status information:
obclient> status;
obclient> \s;
tee, \T and notee, \t
Append all output to a file:
obclient> tee /path/to/output.log;
obclient> SELECT * FROM users;
obclient> notee;
pager, \P and nopager, \n
Set the pager:
obclient> pager less;
obclient> SELECT * FROM large_table;
obclient> nopager;
prompt, \R
Change the prompt:
obclient> prompt \u@\h [\d]>\_
root@localhost [testdb]>
Special sequences in the prompt command
The prompt command allows you to change the default prompt \N [\d]>. The string used to define the prompt can contain the following special sequences:
Options |
Description |
|---|---|
\c |
A counter that increments for each statement you issue. |
\D |
The complete current date. |
\d |
Default database. |
\h |
Server host. |
\l |
The current delimiter. |
\m |
The minutes of the current time. |
\n |
Line break. |
\O |
The current month in three-letter format (Jan, Feb, ...). |
\o |
The current month, in numeric format. |
\P |
am/pm. |
\p |
The current TCP/IP port or socket file. |
\R |
Current time, in 24-hour format (0–23). |
\r |
Current time, in standard 12-hour format (1–12). |
\S |
Semicolon. |
\s |
Seconds of the current time. |
\t |
Tab. |
\U |
Your complete username in the format of user_name@host_name. |
\u |
Your username. |
\v |
Server version. |
\w |
The current day of the week in three-letter format (Mon, Tue, ...). |
\Y |
The current year, in four digits. |
\y |
The current year, in two digits. |
_ |
Space. |
\ |
A space (a backslash followed by a space). |
' |
A single quotation mark. |
" |
Double quotation marks. |
\\ |
Literal backslash character. |
\x |
x, for any "x" not listed above. |
