Learning Mysql



Download 4.24 Mb.
View original pdf
Page96/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   92   93   94   95   96   97   98   99   ...   366
Learning MySQL
The Monitor Help | 99


Geographic Features
Language Structure
Storage Engines
Stored Routines
Table Maintenance
Transactions
Triggers
You may see more or less help content depending on the help files that have been installed with your server. You can get information on individual topics by typing in the HELP command followed by the topic name. For example, to get information on data manipulation, you would type:
mysql> HELP Data Manipulation
You asked for help about help category "Data Manipulation"
For more information, type 'help ', where is one of the following topics:
CACHE INDEX
DELETE
EXPLAIN
INSERT
SELECT
SHOW
SHOW CREATE DATABASE
SHOW CREATE TABLE
SHOW DATABASES
SHOW GRANTS
SHOW STATUS
SHOW TABLES
UPDATE
We’ve omitted some items to keep the output short.
You can request further information on any of the items by typing HELP followed by the appropriate keywords. For example, for information on the SHOW DATABASES
com- mand, you’d type:
mysql> HELP SHOW DATABASES
Name: 'SHOW DATABASES'
Description:
Syntax:
SHOW DATABASES | SCHEMAS} LIKE 'pattern']
100 | Chapter 3:
Using the MySQL Monitor

SHOW DATABASES lists the databases on the MySQL server host. You see only those databases for which you have some kind of privilege, unless you have the global SHOW DATABASES privilege. You can also get this list using the mysqlshow command.
If the server was started with the --skip-show-database option, you cannot use this statement at all unless you have the SHOW DATABASES
privilege.
SHOW SCHEMAS can be used as of MySQL 5.0.2
Running the Monitor in Batch Mode
The MySQL monitor can be used in interactive mode or in batch mode. In interactive mode, you type in SQL queries or MySQL commands such as SHOW DATABASES
at the
MySQL prompt, and view the results.
In batch mode, you tell the monitor to read in and execute a list of commands from a file. This is useful when you need to run a large set of operations—for example, when you want to restore a database from a backup file. It’s also useful when you need to run a particular sequence of operations frequently you can save the commands in a file and then tell the monitor to read in the file whenever you need it.
The examples we’ve presented earlier in this chapter, and most of the examples in this book, show the monitor being used in interactive mode. Let’s look at an example for batch mode. Say you have a text file called count_users.sql containing the SQL
commands:
use mysql;
SELECT COUNT) FROM user;
This script tells MySQL that you want to use the mysql database, and that you want to count all the users who have accounts on the MySQL server (well explain the syntax of the SELECT command in Chapter You can run all the commands in this file using the
SOURCE
command:
mysql> SOURCE count_users.sql
Database changed count) |
+----------+
| 4 |
+----------+
1 row inset sec)
If the count_users.sql file isn’t in the current directory, you should give the full path to the file—for example, /home/adam/Desktop/count_users.sql or C:\count_users.sql. Alternatively, from the command line, you can use the less-than (<) redirection operator followed by the filename:

Download 4.24 Mb.

Share with your friends:
1   ...   92   93   94   95   96   97   98   99   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page