Wk8 - Meta Data & The DBA
Wk8 - Meta Data & The DBA
3
Week 8 Database Management II
Metadata in MySQL
4
Week 8 Database Management II
1. INFORMATION_SCHEMA
5
Week 8 Database Management II
INFORMATION_SCHEMA database
7
Week 8 Database Management II
INFORMATION_SCHEMA Tables cont.
Table Information
COLUMNS: Columns in tables and views
ENGINES: Storage engines
SCHEMATA: Databases
TABLES: Tables in databases
VIEWS: Views in databases
Partitioning
PARTITIONS: Table partitions
FILES: Files in which MySQL NDB disk data tables are stored
Privileges
COLUMN_PRIVILEGES: Column privileges held by MySQL user accounts
SCHEMA_PRIVILEGES: Database privileges held by MySQL user accounts
TABLE_PRIVILEGES: Table privileges held by MySQL user accounts
USER_PRIVILEGES: Global privileges held by MySQL user accounts
8
Week 8 Database Management II
INFORMATION_SCHEMA Tables cont.
9
Week 8 Database Management II
INFORMATION_SCHEMA: Examples
Displays the storage engines used for the
tables in a given database
Finds all the tables that contain SET
columns
Displays the default collation for each
character set
Displays the number of tables in each
database
The INFORMATION_SCHEMA tables are
read-only and cannot be modified with
statements such as INSERT, DELETE, or
UPDATE. The server produces an error if
you execute these types of statements in
an attempt to change the data in the
INFORMATION_SCHEMA tables
Note: Even the DBA “root” is not allowed to
modify the information_schema.
10
Week 8 Database Management II
2. SHOW statements
11
Week 8 Database Management II
SHOW statements cont.
12
Week 8 Database Management II
SHOW statements - Examples
13
Week 8 Database Management II
3. DESCRIBE
14
Week 8 Database Management II
4. mysqlshow
The client program that you can use as a command-line front end
to a few of the SHOW statements.
The arguments you set determine the information to display, and
then the program issues the appropriate SHOW statement and
displays the results of the statement.
15
Week 8 Database Management II
mysqlshow Client
The mysqlshow client provides a command-line interface to various forms of
the SHOW statement that list the names of databases, tables within a
database, or information about table columns or indexes.
General syntax:
shell> mysqlshow [options] [db_name [table_name [column_name]]]
The options part of the mysqlshow client can include any of the standard
connection parameter options, such as –host or –user.
You must supply options if the default connection parameters are not
appropriate. mysqlshow also accepts options that are specific to its own
operation.
Invoke mysqlshow with the –help option to see a complete list of its options.
The action performed by mysqlshow depends on the number of non-option
arguments that are provided.
16
Week 8 Database Management II
mysqlshow: Examples
17
Week 8 Database Management II
mysqlshow: Examples cont
NOTE These examples require the use With a single argument, mysqlshow interprets it as a
database name and displays a result similar to that
of user and password parameters as part of SHOW TABLES for the database.
of command execution. With two arguments, mysqlshow interprets them as
a database and table name and displays a result
similar to that of SHOW FULL COLUMNS for the
table.
With three arguments, the output is the same as for
two arguments except that mysqlshow takes the
third argument as a column name and displays
SHOW FULL COLUMNS output only for that column.
If the final argument on the command line contains
special characters, mysqlshow interprets the
argument as a pattern and displays only the names
that match the pattern. The special characters are %
or * to match any sequence of characters, and _
or ? to match any single character. This example
command shows only those databases with a name
that begins with w.
18
Week 8 Database Management II
User Concept
MySQL Oracle
databases
users users
databases
tables tables
columns columns
19
Week 8 Database Management II
Oracle Metadata
USER_OBJECTS TAB
USER_TABLES USER_VIEWS
ALL_TABLES USER_TAB_COLUMNS
USER_CONSTRAINTS USER_TRIGGERS
USER_CATALOG DBA_USERS
20
Week 8 Database Management II
The DBA
23
Week 8 Database Management II
Area of concern
24
Week 8 Database Management II