0% found this document useful (0 votes)
6 views

Wk8 - Meta Data & The DBA

Uploaded by

aikhomuremen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Wk8 - Meta Data & The DBA

Uploaded by

aikhomuremen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

DATABASE MANAGEMENT II

Dr. Bilkisu L. Muhammad-Bello

Week 8 Database Management II


1
Metadata and the DBA

Week 8 Database Management II


2
Metadata

Metadata literally means “data about data”. It refers to


information about data itself.
Metadata in databases allows them to be self describing.
It means it is a description and context of the database. It
helps to organize, find and understand the DBMS.
DBMS table structure is more than user schema.
Most DBMS systems use tables internally too.

3
Week 8 Database Management II
Metadata in MySQL

MySQL provides access to metadata for databases, tables, and


other objects managed by the database server:
INFORMATION_SCHEMA: The MySQL server contains a data
dictionary implemented as a database (schema) named
INFORMATION_SCHEMA that includes a number of objects that
appear to be tables.
SHOW statements: Proprietary syntax to obtain data on server
statistics, schemas, and schema objects:
DESCRIBE
mysqlshow

4
Week 8 Database Management II
1. INFORMATION_SCHEMA

The metadata information regarding a table is spread across few


tables in INFORMATION_SCHEMA database.

5
Week 8 Database Management II
INFORMATION_SCHEMA database

The INFORMATION_SCHEMA database serves as a central


repository for database metadata. It is a “virtual database” in the
sense that it is not stored anywhere on disk; however, it contains
tables like any other database, and the contents of its tables can
be accessed using SELECT like any other tables. Furthermore,
SELECT statements can be used to obtain
INFORMATION_SCHEMA tables
Because it is a virtual database, MySQL builds query results by
reading table and other object metadata. When you execute a
query that reads information about many tables, MySQL must
execute many disk-level operations, which can take a lot of time.
6
Week 8 Database Management II
INFORMATION_SCHEMA Tables
To list all tables in the INFORMATION_SCHEMA database, use the
below query:

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.

SELECT * FROM TABLES;

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

Obtaining data about database, schemas and tables.

11
Week 8 Database Management II
SHOW statements cont.

The SHOW statement can be used in many forms, as follows:


SHOW DATABASES: Lists the names of the available databases
SHOW TABLES: Lists the tables in the default database
SHOW TABLES FROM [database_name]: Lists the tables in the
specified database
SHOW COLUMNS FROM [table_name]: Displays column structure for
the table
SHOW INDEX FROM [table_name]: Displays information about the
indexes and index columns inthe table
SHOW CHARACTER SET: Displays the available character sets along with
their default collations
SHOW COLLATION: Displays the collations for each character set

12
Week 8 Database Management II
SHOW statements - Examples

13
Week 8 Database Management II
3. DESCRIBE

A SQL statement shortcut you can use to inspect table structure


and column properties.
DESCRIBE can be abbreviated as DESC

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

You can show information for all databases, or for a specific


database, table, and/or column using the mysqlshow query.
For example:
With no arguments, mysqlshow displays a result similar to that of SHOW
DATABASES.

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

Oracle holds system metadata in SYS. E.g.

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

DBA – Database Administrator


Maintain system usability
Provide security
Target for hate mail…

23
Week 8 Database Management II
Area of concern

System performance and tuning


Data backup and recovery
Product+tool selection, install, maintain
System documentation
Support
Education
Future Prediction

24
Week 8 Database Management II

You might also like