Tải bản đầy đủ (.ppt) (48 trang)

slide môn học MySQL bài 3 implementing the SQL queries using MySQL i

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.01 MB, 48 trang )

Implementing the SQL queries
using MySQL-I
Session 6


Review












Databases are used to store information.
Relational Databases consists of several tables
Data types are classified as numeric, String,
Date and Complex
Normalization is the process in which the
redundancies in the database are removed
A Primary key is a field in the table which is
used as the unique identifier
An entity is said to be in the first normal form
if all the attributes are single valued
Indexing a database facilitates a faster find
and sort operations in the database
MySQL Database / Session 6 / Slide 2 of 48




Objectives


View and Alter the database



Select and Display the data from a table



Change the table definition



Delete a table along with its table
definition

MySQL Database / Session 6 / Slide 3 of 48


View Database


SHOW command is
used for viewing
list of
databases

present in the
server
SHOW DATABASES;

MySQL Database / Session 6 / Slide 4 of 48


View Database with LIKE
clause-I


To view the list of databases that begin
or contain the specified character in the
database name, the syntax is:
SHOW DATABASES [LIKE clause];

MySQL Database / Session 6 / Slide 5 of 48


View Database with LIKE
clause-II


Show all
databases that
begin with the
letter ‘E’
SHOW DATABASES
LIKE ‘E%’;


MySQL Database / Session 6 / Slide 6 of 48


View Tables- I


To view a list of tables of a database,
the syntax is:
SHOW TABLES [FROM database_name] [LIKE
clause];

MySQL Database / Session 6 / Slide 7 of 48


View Tables-II


Show the tables
of the Employee
database where
the database is
first activated
with USE command
SHOW TABLES;

MySQL Database / Session 6 / Slide 8 of 48


View Tables using FROM clause



Show the tables of the EMPLOYEE
database
SHOW TABLES FROM EMPLOYEE;

MySQL Database / Session 6 / Slide 9 of 48


View Tables using LIKE clause


Show tables that
begin with the
letter ‘E’ from
the EMPLOYEE
database
SHOW TABLES FROM
EMPLOYEE LIKE ‘E
%’;

MySQL Database / Session 6 / Slide 10 of 48


View Columns-I


To view the column structure of the
specified table from the specified
database, the syntax is:
SHOW COLUMNS FROM table_name [FROM

database_name] [LIKE clauses];

MySQL Database / Session 6 / Slide 11 of 48


View Columns-II


Show the column
structure of the
EMP_DETAILS table
SHOW COLUMNS FROM
EMP_DETAILS;

MySQL Database / Session 6 / Slide 12 of 48


View Columns using LIKE clause


Show columns that
starts with the
letter ‘H’ of the
SALARY_DETAILS
table from EMPLOYEE
database
SHOW COLUMNS FROM
SALARY_DETAILS LIKE
‘H%’;


MySQL Database / Session 6 / Slide 13 of 48


View Index keys-I


To view the index of a table from a
database, the syntax is:
SHOW INDEX FROM table_name [FROM
database_name];

MySQL Database / Session 6 / Slide 14 of 48


View Index Keys-II


Show the index
from the
EMP_DETAILS table
of the EMPLOYEE
database
SHOW INDEX FROM
EMP_DETAILS FROM
EMPLOYEE;

MySQL Database / Session 6 / Slide 15 of 48


View Default Variables



Show the values
of the system
variables
SHOW VARIABLES;

MySQL Database / Session 6 / Slide 16 of 48


View Default Variables using
LIKE clause-I


To view only those variables that match
the specified pattern, the syntax is:
SHOW VARIABLES [LIKE clause];

MySQL Database / Session 6 / Slide 17 of 48


View Default Variables using
LIKE clause-II


Show variables that
matches with the
pattern ‘HAVE’
SHOW VARIABLES LIKE
‘HAVE%’;


MySQL Database / Session 6 / Slide 18 of 48


View Server Status


Show the server
status
SHOW STATUS;

MySQL Database / Session 6 / Slide 19 of 48


View Table Status-I


To display more information about tables,
the syntax is:
SHOW TABLE STATUS [FROM database_name]
[LIKE clauses];

MySQL Database / Session 6 / Slide 20 of 48


View Table Status-II


Show the status of
all the tables of

the EMPLOYEE
database
SHOW TABLE STATUS
FROM EMPLOYEE;

MySQL Database / Session 6 / Slide 21 of 48


View rights of a user-I


To view a list of grants that can be
issued to duplicate grants for a user,
the syntax is:
SHOW GRANTS FOR user;

MySQL Database / Session 6 / Slide 22 of 48


View rights of a user-II


Show the list
of grants that
are issued to
root user
SHOW GRANTS FOR
root@localhost;

MySQL Database / Session 6 / Slide 23 of 48



Altering Database on the
file system-I


To modify the character set of a database,
the syntax is:
ALTER DATABASE database_name DEFAULT
CHARACTER SET charset_name;

MySQL Database / Session 6 / Slide 24 of 48


Altering Database on the
file system-II


To modify the character set to swe7 of a temporary
database named as TEST
ALTER DATABASE TEST DEFAULT CHARACTER SET swe7;

MySQL Database / Session 6 / Slide 25 of 48


×