MYSQL: Introduction<br />
OVERVIEW OF MYSQLwhat is mysql?Where to download mysql?What is database?What is sql?Basic queries in mysql?<br />
MYSQLMysql is the most popular open source database system Mysql is a relational databasemanagement system It is a free SQ...
STEPS TO DOWNLOAD MYSQL1.goto www.mysql.com2.click on downloads3.choose the host operating system4.download and run mysql5...
DatabaseData: known facts that can be recorded and that have implicit meaningDatabase: collection of related data.It is a ...
Goals of a DBMS:To provide an efficient and convenient environment for accessing data in dbIt is a general purpose facilit...
SQL-structured query languagesql is now the standard language for commercial relational DBMS.It has statements for data de...
START MYSQL SERVER:log in as root under linux with the command safe_mysqld &1) without any password:mysql -u &lt;user&gt; ...
BASIC QUERIES IN MYSQL1.CREATE TABLE    create table table_name(column1 data type(NULL||NOT NULL);desc: creates a table.2....
 3.INSERT insert into table_namevalues[‘value1’,’value2’,……..);desc: inserts new rows of data into the database.4.SELECTse...
5.SELECTselect column1,column2,…from table1,table2,….[where conditions][group by column1,column2,..][having conditions][or...
6.UPDATEupdate table_name set column1=‘value1’,column2=‘values’,…[where conditions]desc: updates existing data in the tabl...
Mysql classes1.SELECTselect *select col1,col2,…select distinct(column)select count(*)desc: defines columns to display as p...
2.FROMfrom table1,table2,table3,..Desc: defines tables from which to retrieve data.3. GROUP BYgroup by grp_col1,grp_col2,…...
4.HAVINGhaving grp_col1=‘value1’AND grp_col2=‘value2’desc: similar to the where clause, used to place conditions on the gr...
mysql functions:1.rand()desc: returns random values2.sum()desc: returns the sum of the values.3.now()desc: returns the tim...
sample code to create a table employee and run  basic queries using mysql on windows operating system:<br />Mysql&gt;creat...
Mysql&gt;insert into employee<br />Values(100,10000,’sneha’,’finance’);<br />Query ok, 1 row affected(0.04 sec)<br />Mysql...
Mysql&gt;insert into employee<br />Values(300,30000,’john’,’finance’);<br />Query ok, 1 row affected(0.04 sec)<br />Mysql&...
Mysql&gt;select * from employee;<br />
Mysql&gt;select department, count(*) as number from employee group by department order by number desc;<br />
Mysql&gt;DESC EMPLOYEE;<br />
Mysql&gt;show create table employee;<br />
Mysql&gt; select name, ssn from employee order by ssn desc limit 2;<br />
Mysql&gt;update employee set salary=9000 where ssn=400;Mysql&gt;select * from employee;<br />
Mysql&gt;delete from employeewhere name=‘jack’;mysql&gt;select * from employee;<br />
Mysql&gt;drop table employee;query ok, 0 rows affected (0.04 sec)Mysql&gt;select * from employee;ERROR 1146 (42S02): Table...
Advantages of mysql:<br />1.Its most reliable.<br />2.Easy to use.<br />3.Very fast.<br />4.Multithreaded<br />multi-user ...
Visit more self help tutorials<br />Pick a tutorial of your choice and browse through it at your own pace.<br />The tutori...
Upcoming SlideShare
Loading in...5
×

MySql:Introduction

1,042

Published on

MySql:Introduction

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,042
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

MySql:Introduction

  1. 1. MYSQL: Introduction<br />
  2. 2. OVERVIEW OF MYSQLwhat is mysql?Where to download mysql?What is database?What is sql?Basic queries in mysql?<br />
  3. 3. MYSQLMysql is the most popular open source database system Mysql is a relational databasemanagement system It is a free SQL server database server licensed with GNU www.gnu.org<br />
  4. 4. STEPS TO DOWNLOAD MYSQL1.goto www.mysql.com2.click on downloads3.choose the host operating system4.download and run mysql5.go back and click on gui tools6.download and run mysql gui tools<br />
  5. 5. DatabaseData: known facts that can be recorded and that have implicit meaningDatabase: collection of related data.It is a logical collection of coherent data with some inherent meaning.DBMS: A computerised record-keeping system.<br />
  6. 6. Goals of a DBMS:To provide an efficient and convenient environment for accessing data in dbIt is a general purpose facility for:Defining dbConstructing dbManipulating db<br />
  7. 7. SQL-structured query languagesql is now the standard language for commercial relational DBMS.It has statements for data definitions, queries and updates.<br />
  8. 8. START MYSQL SERVER:log in as root under linux with the command safe_mysqld &1) without any password:mysql -u &lt;user&gt; -h &lt;host&gt;2)with password:mysql -u &lt;user&gt; -h &lt;host&gt; -p ex: mysql –u root –h localhostdesc: -u option is used to log in as a root and –p option tells mysql to query for the password.<br />
  9. 9. BASIC QUERIES IN MYSQL1.CREATE TABLE create table table_name(column1 data type(NULL||NOT NULL);desc: creates a table.2.SHOW table show CREATE TABLE table_name;desc: shows the table in your database.<br />
  10. 10. 3.INSERT insert into table_namevalues[‘value1’,’value2’,……..);desc: inserts new rows of data into the database.4.SELECTselect * from table table_name.desc: returns data from the table.<br />
  11. 11. 5.SELECTselect column1,column2,…from table1,table2,….[where conditions][group by column1,column2,..][having conditions][order by column1,column2,…]desc: returns data from one or more database tables.<br />
  12. 12. 6.UPDATEupdate table_name set column1=‘value1’,column2=‘values’,…[where conditions]desc: updates existing data in the table.7.DELETEdelete from table_name[where conditions]desc: deletes rows of data from a table.<br />
  13. 13. Mysql classes1.SELECTselect *select col1,col2,…select distinct(column)select count(*)desc: defines columns to display as part of query output.<br />
  14. 14. 2.FROMfrom table1,table2,table3,..Desc: defines tables from which to retrieve data.3. GROUP BYgroup by grp_col1,grp_col2,…desc: a form of a sorting. Used to divide output into logical groups.<br />
  15. 15. 4.HAVINGhaving grp_col1=‘value1’AND grp_col2=‘value2’desc: similar to the where clause, used to place conditions on the group clause.5.ORDER BYorder by col1,col2,…desc: used to sort a query’s result.<br />
  16. 16. mysql functions:1.rand()desc: returns random values2.sum()desc: returns the sum of the values.3.now()desc: returns the time and date of the system.4.count()desc: returns the count of the values which satisfy the given condition.<br />
  17. 17. sample code to create a table employee and run basic queries using mysql on windows operating system:<br />Mysql&gt;create table employee(<br />Ssn INT NOT NULL,<br />Salary INT,<br />Name VARCHAR(20),<br />Primary key(ssn));<br />Query ok, 0 rows affected (0.04 sec)<br />
  18. 18. Mysql&gt;insert into employee<br />Values(100,10000,’sneha’,’finance’);<br />Query ok, 1 row affected(0.04 sec)<br />Mysql&gt;insert into employee<br />Values(200,20000,’shalini’,’hr’);<br />Query ok, 1 row affected(0.04 sec)<br />
  19. 19. Mysql&gt;insert into employee<br />Values(300,30000,’john’,’finance’);<br />Query ok, 1 row affected(0.04 sec)<br />Mysql&gt;insert into employee<br />Values(400,40000,’jack’,’hr’);<br />Query ok, 1 row affected(0.04 sec)<br />
  20. 20. Mysql&gt;select * from employee;<br />
  21. 21. Mysql&gt;select department, count(*) as number from employee group by department order by number desc;<br />
  22. 22. Mysql&gt;DESC EMPLOYEE;<br />
  23. 23. Mysql&gt;show create table employee;<br />
  24. 24. Mysql&gt; select name, ssn from employee order by ssn desc limit 2;<br />
  25. 25. Mysql&gt;update employee set salary=9000 where ssn=400;Mysql&gt;select * from employee;<br />
  26. 26. Mysql&gt;delete from employeewhere name=‘jack’;mysql&gt;select * from employee;<br />
  27. 27. Mysql&gt;drop table employee;query ok, 0 rows affected (0.04 sec)Mysql&gt;select * from employee;ERROR 1146 (42S02): Table ‘mysql.employee’ doesn’t existuse quit or exit to come out of mysql.Mysql&gt;quit<br />
  28. 28. Advantages of mysql:<br />1.Its most reliable.<br />2.Easy to use.<br />3.Very fast.<br />4.Multithreaded<br />multi-user and<br />5.Robust sql<br />database server.<br />
  29. 29. Visit more self help tutorials<br />Pick a tutorial of your choice and browse through it at your own pace.<br />The tutorials section is free, self-guiding and will not involve any additional support.<br />Visit us at www.dataminingtools.net<br />

×