MySQL, MYSQL, and mysqlTheyre Not the Same Thing

only for RuBoard - do not distribute or recompile

MySQL, MYSQL, and mysql”Theyre Not the Same Thing

MySQL, MYSQL, and mysql are three very different things. When each one is used, it references something different from the others. Throughout this chapter and the entire book, when you see one of these terms, remember that it refers to something very specific:

  • MySQL is the overall database”the entire package.

  • MYSQL is a C API structure for managing a connection to a database.

  • mysql is the client package”the tool you use to communicate with a MySQL database server from the command line. It is also the name of the database that stores system information (what you might expect to be called sysobjects or systables in other databases).

mysql: The Command-Line Interface

The program mysql is really one of a suite of utilities for accessing and managing MySQL. The mysql program has been the standard way to access data in a MySQL implementation. It is roughly equivalent to MS SQL Servers isql or osql utility.

mysql is normally used as described here. From the command prompt, type mysql. This causes the command prompt to change to mysql> . Type in your SQL statement, and terminate it with a semicolon:

 % mysql  mysql> select * from tbl_sales_people; 

Usage:

 % mysql [OPTIONS] [database_name] 

The mysql program takes several command-line flags that are of interest. They are listed in Table 1.3

Table 1.3. The More Common mysql Command Flags

Option Short

Option Long

Description

-B

--batch

Runs in batch; results are output in tab-delimited format with column headers in the first row. To suppress column headers, use the --skip-column- names option.

-T

--debug- info

Outputs debug info at program end. The information includes such things as user time, page faults, and so on.

-e qry

--execute=qry

Executes the query specified, and then quits. Enclose qry in quotation marks; separate multiple queries with semicolons.

-f

--force

Continues processing when an error occurs; the default behavior is to exit when an error occurs.

-H

--html

Outputs in HTML. Specifically, inserts table tags into the data output.

-I

--ignore-space

Ignores spaces between function names and the parentheses that hold the argument list. The default behavior requires that the first parenthesis immediately follow the function name.

-q

--quick

Displays each row as it is retrieved; the default is to wait for all rows from the server before displaying.

-N

--skip-column-names

Does not display column headers in results.

-t

--table

Outputs in table format, with columns lined up and separated by vertical bars (the character). This is the default.

-E

--vertical

Prints query results vertically, each line with a column name and value.

-w

--wait

Waits and attempts again to connect to the MySQL server if a connection cannot be made.

In addition, from the mysql> prompt, you can issue a number of commands. These are listed in Table 1.4

Table 1.4. Common Commands to Use at the mysql> Prompt

Short Command

Long Command

Description

\c

clear

Cancels a command; not for queries that have been sent and are in the process of returning results.

\r

connect

Connects to a specified host. Usage:

\r [database_name [host_name]] connect [database_name [host_name]]

\e

edit

Edits the current query; uses vi as the default. When you invoke this command, you are taken to the vi edit screen. When finished, you return to the mysql prompt, with your altered query in the buffer. Enter a semicolon to execute the query you edited in vi.

 

exit

 
 

quit

Terminates the mysql program.

\g or ;

go

Sends the current query to the server.

\h

help

Displays the available mysql commands and flags.

\p

print

Prints the current query, not the query results.

\#

rehash

Completes the database, table, and column. Actually, this command orders a refresh of the information needed for the completion functionality.

\s

status

Displays the server version and current database, connection id, server version, uptime, and such.

\u

use

Selects a certain database as the current database. Usage:

mysql> use database_name

mysql> \u database_name

only for RuBoard - do not distribute or recompile


MySQL Building User Interfaces
MySQL: Building User Interfaces (Landmark)
ISBN: 073571049X
EAN: 2147483647
Year: 2001
Pages: 119

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net