Download presentation
Presentation is loading. Please wait.
Published byChristina Ellis Modified over 9 years ago
1
Information Systems Today (©2006 Prentice Hall) MySQL 1CS3754 Class Note #8, 2013 1.Is an open-source relational database management system 2.Is fast and stable 3.Is available as free software and as commercial software 4.Supports the majority of features considered important by the database community 5.Is a great tool for learning about databases
2
Information Systems Today (©2006 Prentice Hall) Installing MySQL You can download MySQL from You can download MySQL from www.mysql.com/down loads You can run MySQL on Linux on the computer system of our department by executing: You can run MySQL on Linux on the computer system of our department by executing: mysql –h stretch –u username -p 2CS3754 Class Note #8, 2013
3
Information Systems Today (©2006 Prentice Hall) Introduction to MySQL Monitor After logged in you can see what databases exist on the system by: After logged in you can see what databases exist on the system by: show database; You can select a database from the listed database names by: You can select a database from the listed database names by: use databasename; After selecting a database, you can see what table are in it by: After selecting a database, you can see what table are in it by: show tables; 3CS3754 Class Note #8, 2013
4
Information Systems Today (©2006 Prentice Hall) Introduction to MySQL Monitor You can get information on a particular table by: You can get information on a particular table by: describe tablename; You can log out of the monitor by: \q You can log out of the monitor by: \q You can get a help by: \h You can get a help by: \h You can execute a file of commands You can execute a file of commands When logged into the monitor by : Source filename When logged into the monitor by : Source filename When not logged into the monitor by: When not logged into the monitor by: mysql –u username –p < filename /* -u means username –p means login with password 4CS3754 Class Note #8, 2013
5
Information Systems Today (©2006 Prentice Hall) Creating Databases and Tables Creating a database by Creating a database by create database databasename; Creating a table by Creating a table by create table tablename (table definition) [type = table_type]; Ex: create table dept (deptID int not null auto_increment primary key, Name varchar(30)) type=InnoDB 5CS3754 Class Note #8, 2013
6
Information Systems Today (©2006 Prentice Hall) Dropping Databases and Tables Drop a database by Drop a database by drop database databasename; Drop a table by Drop a table by drop table tablename; 6CS3754 Class Note #8, 2013
7
Information Systems Today (©2006 Prentice Hall) Inserting, Deleting, and Updating Data Deleting by: delete from dept Deleting by: delete from dept Inserting by: Inserting by: insert into dept values (42, ‘Finance’ ), (128, ‘Research and Development’ ); Update by: Update by: update employee set job = ‘DBA’ where employeeID = “6651’; 7CS3754 Class Note #8, 2013
8
Information Systems Today (©2006 Prentice Hall) Uploading data with Load Data Infile The Load Data Infile command allows you to bulk insert data from a text file into a single table without having to write Insert statements. The Load Data Infile command allows you to bulk insert data from a text file into a single table without having to write Insert statements. Example: Example: load data local infile ‘dept_infile.txt’ into table dept; /* Local means the data file is on the client machine not on the server. */ 8CS3754 Class Note #8, 2013
9
Information Systems Today (©2006 Prentice Hall) Querying MySQL Select columns from tables: Select columns from tables: select * from dept; select name, employeeID from employee; Using joins to run queries over multiple tables: Using joins to run queries over multiple tables: select employee.name as EmployeeName, dept.name as deptName from employee, dept where employee.deptID = dept.deptID; 9CS3754 Class Note #8, 2013
10
Information Systems Today (©2006 Prentice Hall) Table Types in MySQL ISAM, having replaced by MyISAM ISAM, having replaced by MyISAM MyISAM as the default type MyISAM as the default type Offer very fast but not transaction-safe storage Offer very fast but not transaction-safe storage InnoDB InnoDB Offer very fast and transaction-safe storage Offer very fast and transaction-safe storage Row-level locking Row-level locking Supports for foreign keys Supports for foreign keys Tables are portable from systems to systems Tables are portable from systems to systems BerkeleyDB (BDB) BerkeleyDB (BDB) Offer transaction-safe storage but slightly worse performance than InnoDB Offer transaction-safe storage but slightly worse performance than InnoDB MERGE MERGE Used to treat multiple MyISAM tables as a single table Used to treat multiple MyISAM tables as a single table HEAP HEAP Stored only in memory and need to be limited in size Stored only in memory and need to be limited in size 10CS3754 Class Note #8, 2013
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.