1 / 18

COMP 5531

COMP 5531. Introduction to MySQL. SQL. SQL is a standard language for accessing and managing databases. SQL stands for Structured Query Language. What can SQL do?. Retrieve data from a database. Insert records in a database. Update existing records. Delete records. Create new database.

mimi
Download Presentation

COMP 5531

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 • http://dev.mysql.com/downloads/

  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_Idint, LastNamevarchar(255), FirstNamevarchar(255), GPA decimal(3,2), DOB date);

  10. Managing the table • DESC mytable; • DROP TABLE mytable;

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

  12. Example of inserting data insert into mytable values (6246893,'Krishnan','Giri',3.44,'1987-03-03');

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

  14. Example of viewing data • select * from mytable; • select student_id, gpafrom mytable;

  15. View data with a WHERE clause • SELECT column_name,column_nameFROM table_nameWHERE column_name operator value • select * from mytable where student_id= 6246893;

  16. Operators in the WHERE clause

  17. Select DISTINCT data • SELECT DISTINCT column_name,column_nameFROM table_name; • select distinct firstname from mytable;

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

More Related