Uploaded by monaalamri77

Lab#3

advertisement
Kingdom of Saudi Arabia
Taif University
CIT College
Instructors :
Mrs. Mashael , Ms. Munirah , Ms.Shameem
Lab#3
Introduction to MySQL
2

An open source , Enterprise-level , multi threaded,
relational database management system.

MySQL is a program that manages databases.

Can have number of simultaneous connections

Security is unparalleled.

Flexible and easy to use.
Installation of MYSQL
3
4
5
6
7
8
Using MySQL- Command Line
9
View the existing database
10





Take a look at the existing databases in the
default installation.
Type the following:
show databases;
Commands should end with ; or \g.
Basic MySQL Commands
11
•
•
•
•
•
•
•
show databases- to see the existing databases
create database [database name] – to create new
database called “database name”
show tables- to see all the tables
Show tables from test – shows all the tables from the
database named test
describe [table name]-To see database's field
formats.
Use database name-To use the database called
database name for any purpose.
Drop database test – to delete a database called
test.
SQL Command types
12
SQL commands are divided into a number of categories
• 1. Data Definition Language commands (DDL): statements
allow you to create, remove and modify tables (and other
objects) in a relational database.
• 2. Data Manipulation Language commands (DML): statements
affect the records in a table.
• 3. Transaction Control command (TCL): statements to apply
the transaction by saving the database changes, undo all
changes of a transaction and to divide the transaction into
smaller sections.
• 4. Session Control command/ Data Control Language (DCL):
statements allow specified users to perform specific tasks and
to cancel previously granted or denied permissions.
Basic commands contd….
13
•
•
•
•
Describe tablename- to see al the columns in your table
SELECT * FROM [table name]- Show all data in a table.
Rename – to rename any database or tables in database.
Alter – this command helps to change the database
properties or table properties etc.
eg: altertable t1 rename t2
• INSERT INTO tablename (col1, col2) VALUES('data1', 'data2' )to insert values to the colomns in table
• Truncate - TRUNCATE TABLE tablename; This will delete all
data in the table very quickly
14
Create the following database
Student_Record with the following
tables(MySQL).
15
16
17
18
19
The End
Download