Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP 5531 Introduction to MySQL. SQL SQL is a standard language for accessing and managing databases. SQL stands for Structured Query Language.

Similar presentations


Presentation on theme: "COMP 5531 Introduction to MySQL. SQL SQL is a standard language for accessing and managing databases. SQL stands for Structured Query Language."— Presentation transcript:

1 COMP 5531 Introduction to MySQL

2 SQL SQL is a standard language for accessing and managing databases. SQL stands for Structured Query Language.

3 What can SQL do? Retrieve data from a database. Insert records in a database. Update existing records. Delete records. Create new database. Create new tables etc.

4 SQL Components SQL has three main parts. – DDL (Data Definition Language) CREATE TABLE, DROP TABLE, ALTER TABLE – DML (Data Manipulation Language) SELECT, INSERT, UPDATE, DELETE – DCL (Data Control Language) GRANT, REVOKE

5 MySql Based on RDBMS. (Relational Database Management System) The most popular Open Source SQL. Download link –

6 Manage Your Database CREATE DATABASE database_name; SHOW DATABASES; USE database_name; DROP DATABASE database_name; SHOW TABLES;

7 Create table CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type,.... );

8 Data types Kind of values it can represent

9 An example of Create Table CREATE TABLE mytable (Student_Id int, LastName varchar(255), FirstName varchar(255), GPA decimal(3,2), DOB date);

10 Managing the table DESC mytable; DROP TABLE mytable;

11 Inserting data into table INSERT INTO table_name VALUES (value1,value2,value3,...); Or INSERT INTO table_name (column1,column2,...) VALUES (value1,value2,...);

12 Example of inserting data insert into mytable values ( ,'Krishnan','Giri',3.44,' ');

13 Viewing data in the table SELECT column_name,column_name FROM table_name; And SELECT * FROM table_name;

14 Example of viewing data select * from mytable; select student_id, gpa from mytable;

15 View data with a WHERE clause SELECT column_name,column_name FROM table_name WHERE column_name operator value select * from mytable where student_id = ;

16 Operators in the WHERE clause OperatorDescription =Equal <>Not equal >Greater than =Greater than or equal <=Less than or equal BETWEENBetween an inclusive range LIKESearch for a pattern INTo specify multiple possible values for a column

17 Select DISTINCT data SELECT DISTINCT column_name,column_name FROM table_name; select distinct firstname from mytable;

18 SQL Constraints NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY CHECK DEFAULT


Download ppt "COMP 5531 Introduction to MySQL. SQL SQL is a standard language for accessing and managing databases. SQL stands for Structured Query Language."

Similar presentations


Ads by Google