Creating And Using A Database - Oracle 5.0 Reference Manual

Table of Contents

Advertisement

example,
'hello'
you see a
'>
"'" or """ quote character, but have not yet entered the matching quote that terminates the string. This
often indicates that you have inadvertently left out a quote character. For example:
mysql>
SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
'>
If you enter this
of wondering why this query takes so long, notice the clue provided by the
expects to see the rest of an unterminated string. (Do you see the error in the statement? The
mysql
string
'Smith
At this point, what do you do? The simplest thing is to cancel the command. However, you cannot just
type
in this case, because
\c
the closing quote character (so
mysql>
SELECT * FROM my_table WHERE name = 'Smith AND age < 30;
'>
'\c
mysql>
The prompt changes back to mysql>, indicating that
The
prompt is similar to the
`>
completed a backtick-quoted identifier.
It is important to know what the '>, ">, and
an unterminated string, any further lines you type appear to be ignored by mysql—including a line
containing QUIT. This can be quite confusing, especially if you do not know that you need to supply the
terminating quote before you can cancel the current command.

3.3. Creating and Using a Database

Once you know how to enter commands, you are ready to access a database.
Suppose that you have several pets in your home (your menagerie) and you would like to keep track
of various types of information about them. You can do so by creating tables to hold your data and
loading them with the desired information. Then you can answer different sorts of questions about
your animals by retrieving data from the tables. This section shows you how to perform the following
operations:
• Create a database
• Create a table
• Load data into the table
• Retrieve data from the table in various ways
• Use multiple tables
The menagerie database is simple (deliberately), but it is not difficult to think of real-world situations
in which a similar type of database might be used. For example, a database like this could be used by
a farmer to keep track of livestock, or by a veterinarian to keep track of patient records. A menagerie
distribution containing some of the queries and sample data used in the following sections can be
obtained from the MySQL Web site. It is available in both compressed
dev.mysql.com/doc/.
Use the
SHOW
mysql>
SHOW DATABASES;
+----------+

Creating and Using a Database

or "goodbye"), and
or
prompt, it means that you have entered a line containing a string that begins with a
">
statement, then press Enter and wait for the result, nothing happens. Instead
SELECT
is missing the second single quotation mark.)
mysql
mysql
and
'>
statement to find out what databases currently exist on the server:
lets you enter strings that span multiple lines. When
mysql
interprets it as part of the string that it is collecting. Instead, enter
knows you've finished the string), then type \c:
mysql
prompts, but indicates that you have begun but not
">
prompts signify, because if you mistakenly enter
`>
197
prompt. It tells you that
'>
is ready for a new command.
file and Zip formats at
tar
http://

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents