SlideShare una empresa de Scribd logo
1 de 32
MY SQL INSTALLATION AND  CONFIGERATION WITH QUERY BY , NIRMAL FELIX.K
INTRODUCTION: MySQL, the most popular Open Source SQL database management system,  is developed, distributed, and supported by MySQL AB.  MySQL AB is a commercial company, founded by the MySQL developers.  It is a second generation Open Source company that unites  Open Source values and methodology with a successful business model.
MySQL is a fast, stable and true multi-user,  multi-threaded SQL database server.  SQL (Structured Query Language) is the most popular  database query language in the world.  The main goals of MySQL are speed, robustness and ease of use.
Installing MySQL on Linux It's simple to install MySQL on Linux using the RPM file. 1. Become the superuser if you are working in your account.  (Type "su" and the prompt and give the root password). 2. Change to the directory that has the RPM download. 3. Type the following command at the prompt: rpm -ivh "mysql_file_name.rpm" Similarly you can also install the MySQL client and MySQL development RPMs  if you've downloaded them. Alternatively, you can install the RPMs through GnoRPM (found under System).
You can check your configuration using the following command #netstat -tap Output Looks like below tcp 0 0 *:mysql *:* LISTEN 4997/mysqld MySQL comes with no root password as default.  This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too.  The local-machine-name is the name of the  KonaLink1KonaLink1computer  you’re working on.  For more information see here #mysqladmin -u root password your-new-password #mysqladmin -h root@local-machine-name -u root -p password your-new-password #/etc/init.d/mysql restart
4. Now we'll set a password for the root user. Issue the following at the prompt. mysqladmin -u root password mysqldata where mysqldata is the password for the root. (Change this to anything you like). 5. It is now time to test the programs. Typing the following at the prompt starts the mysql client program. mysql -u root -p The system asks for the the password. Type the root password (mysqldata). If you don't get the prompt for password, it might be because MySQL Server is not running.  To start the server, change to /etc/rc.d/init.d/ directory and issue the command ./mysql start  (or mysql start depending on the value of the PATH variable on your system).  Now invoke mysql client program.
6. Once MySQL client is running, you should get the mysql> prompt. Type the following at this prompt: show databases; 7. You should now get a display similar to: +----------------+ | Database  | +----------------+ | mysql  | | test  | +----------------+ 2 rows in set (0.00 sec)
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Frequently this registration process is done by the editing  of a special application-specific configuration file either  via a Web GUI or from the command line. Read your application's installation guide for details.  You should always remember that MySQL is just a database that your application  will use to store information.  The application may be written in a variety of languages with Perl and PHP being the most popular. The base PHP and Perl RPMs are installed with Fedora Linux by default,  but the packages used by these languages to talk to MySQL are not.  You should also ensure that you install the RPMs listed in Table 34.1 on your MySQL clients to ensure compatibility. Use the yum utility discussed in Chapter 6, " Installing Linux Software ",  if you are uncertain of the prerequisite RPMs needed.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SQL Constraints Constraints are used to limit the type of data that can go into a table. Constraints can be specified when a table is created  (with the CREATE TABLE statement) or after the table is created  (with the ALTER TABLE statement). We will focus on the following constraints: * NOT NULL * UNIQUE * PRIMARY KEY * FOREIGN KEY * CHECK * DEFAULT
BASIC MySQL COMMAND * CREATE TABLE syntax * DROP TABLE syntax * DELETE syntax  * SELECT syntax  * JOIN syntax  * INSERT syntax  * REPLACE syntax  * UPDATE syntax
BASIC QURIES CREATE TABLE This command is used to create structure of the table. Syntax : Create table <tablename>(list of col  Definition1,....); Example: Create table emp1 (Emp ID (number(3)  primary key, Name(varchar(20), Age(number(),  DOB(date));
DROP TABLE Syntax: Drop table [if exists]  tbl_name Explanation:   DROP TABLE removes one or more tables. All table data and the table definition are removed.You can use the keywords IF EXISTS to prevent an error from  occurring for tables that don't exist.
DELETE Syntax: Delete from <tablename>; Example: Delete from emp1; Explanation: This command is used to delete the rows and column.
SELECT Syntax: Select * from <tablename>; Example: Select * from emp1; Explanation: This command is used to describe the structure of the table.
INSERT VALUE Syntax: Insert into <tablename> values (list of values); Example: Insert into emp1 values (11, Anu, 20,30-aug-1989); Explanation: This command is used to insert values into the structure of the table.
REPLACE   Syntax: REPLACE  [INTO] tbl_name [(col_name,...)] VALUES (expression,...) Explanation:   REPLACE works exactly like INSERT, except that if an old record in the table has the same value as a new record on a unique index, the old record is  deleted before the new record is inserted.
UPDATE Syntax: UPDATE [table] SET [column]=[value] WHERE [criteria]  UPDATE Used_Vehicles SET mileage=66000 WHERE vehicle_id=1;  UPDATE [table] SET [column]=[value] WHERE [criteria]  Example: UPDATE Used_Vehicles SET mileage=66000 WHERE vehicle_id=1;  Explanation:  UPDATE updates columns in existing table rows with new values. The SET clause indicates which columns to modify and the values they should be given. The WHERE clause, if given, specifies which rows should be updated. Otherwise all rows are updated.
ADVANCED COMMANDS ,[object Object],[object Object],[object Object],[object Object],[object Object]
AS Syntax: SELECT <columns>FROM <existing_table_name>AS <new_table_name> Example:  SELECT t1.name -> FROM artists -> AS t1;  Explanation:  It is used to create a shorthand reference to elements with long names to make the SQL statements shorter and reduce the chance of typos in the longer names.
ALTERING THE DATABASE STRUCTURE AND  ADDING DATA Syntax: ALATER TABLE tablename ADD clm_name type Example:   ALTER TABLE cds  ->  ADD producerID INT(3);
UNION JOINS Syntax:  Select <fields>from <table> where <condition> union SELECT <fields>  FROM <table>WHERE <condition> Example:  SELECT artist FROM artists WHERE (artists.name LIKE 'P%')  UNION SELECT artists.name FROM artists WHERE (artists.name LIKE 'G%'); Explanation:  Union Joins allow the results of two queries to be combined into one outputted result set. This is done by having the 2 (or more) queries glued together by the UNION operator.
CREATING THE TEMPORARY TABLE Definition:  The syntax for creating temporary tables is almost identical that used for creating a normal table. Except that there is an extra TEMPORARY clause.  Syntax:  CREATE TEMPORARY TABLE <table> (field definition)  CREATE TEMPORARY TABLE <newtable>SELECT * FROM <oldtable>
TRUNCATE TABLE Syntax:  TRUNCATE TABLE <table_name> Example:  TRUNCATE TABLE emp1;
TRUNCATE( ) Syntax:  TRUNCATE(X,D) Use:  This function is used to return the value of X truncated to D number of decimal places.
INSERT( ) Syntax:  INSERT(str,pos,len,newstr) Use:  Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr.
The UPDATE Statement The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value
The DELETE Statement The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value
To export a database, use the mysqldump utility normally located in your mysql/bin directory . For example, to export all the tables and data for a database named guestdb. Syntax: mysqldump guestdb > guestdb.txt Exporting a Database
This will create a text file containing all the commands necessary to recreate all the tables and data found in guestdb. However, what if I want to export only one table? To do this the command is modified as follows assuming guestTbl is the table to be exported. Syntax: mysqldump guestdb guestTbl > guestdb.txt
With the data in a text file, its time to import the data back into MySQL. This can be done by passing the commands contained in the text file into the MySQL client.  For example: mysql -p --user=username < guestdb.txt This passes all the commands in the file into the mysql client just like you were typing them in. Importing the Database

Más contenido relacionado

La actualidad más candente

Pluggable database tutorial 2
Pluggable database tutorial 2Pluggable database tutorial 2
Pluggable database tutorial 2Osama Mustafa
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain ExplainedJeremy Coates
 
Amazon aurora 1
Amazon aurora 1Amazon aurora 1
Amazon aurora 1EXEM
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLPadraig O'Sullivan
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slidesmetsarin
 
Data Processing Inside PostgreSQL
Data Processing Inside PostgreSQLData Processing Inside PostgreSQL
Data Processing Inside PostgreSQLEDB
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group ReplicationDave Stokes
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterI Goo Lee
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptFramgia Vietnam
 

La actualidad más candente (20)

Pluggable database tutorial 2
Pluggable database tutorial 2Pluggable database tutorial 2
Pluggable database tutorial 2
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain Explained
 
Refcard en-a4
Refcard en-a4Refcard en-a4
Refcard en-a4
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
MySQL 5.5
MySQL 5.5MySQL 5.5
MySQL 5.5
 
Msql
Msql Msql
Msql
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
Amazon aurora 1
Amazon aurora 1Amazon aurora 1
Amazon aurora 1
 
MySql:Introduction
MySql:IntroductionMySql:Introduction
MySql:Introduction
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQL
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
PostgreSQL Database Slides
PostgreSQL Database SlidesPostgreSQL Database Slides
PostgreSQL Database Slides
 
Data Processing Inside PostgreSQL
Data Processing Inside PostgreSQLData Processing Inside PostgreSQL
Data Processing Inside PostgreSQL
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
 
Introduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB ClusterIntroduction to MySQL InnoDB Cluster
Introduction to MySQL InnoDB Cluster
 
Mysql all
Mysql allMysql all
Mysql all
 
Createclone
CreatecloneCreateclone
Createclone
 
My sql
My sqlMy sql
My sql
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 

Destacado (6)

Apache
ApacheApache
Apache
 
Ajax
AjaxAjax
Ajax
 
Css
CssCss
Css
 
Cai
CaiCai
Cai
 
Invitatie la botez Laurentiu
Invitatie la botez LaurentiuInvitatie la botez Laurentiu
Invitatie la botez Laurentiu
 
Cai
CaiCai
Cai
 

Similar a My sql with querys

Similar a My sql with querys (20)

MYSQL
MYSQLMYSQL
MYSQL
 
Raj mysql
Raj mysqlRaj mysql
Raj mysql
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
Mysql
MysqlMysql
Mysql
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling Presentation
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdfmysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
mysqlanditsbasiccommands-150226033905-conversion-gate02.pdf
 
MySQL Reference Manual
MySQL Reference ManualMySQL Reference Manual
MySQL Reference Manual
 
Sq lite
Sq liteSq lite
Sq lite
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
Database COMPLETE
Database COMPLETEDatabase COMPLETE
Database COMPLETE
 

Último

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

My sql with querys

  • 1. MY SQL INSTALLATION AND CONFIGERATION WITH QUERY BY , NIRMAL FELIX.K
  • 2. INTRODUCTION: MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by MySQL AB. MySQL AB is a commercial company, founded by the MySQL developers. It is a second generation Open Source company that unites Open Source values and methodology with a successful business model.
  • 3. MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query language in the world. The main goals of MySQL are speed, robustness and ease of use.
  • 4. Installing MySQL on Linux It's simple to install MySQL on Linux using the RPM file. 1. Become the superuser if you are working in your account. (Type &quot;su&quot; and the prompt and give the root password). 2. Change to the directory that has the RPM download. 3. Type the following command at the prompt: rpm -ivh &quot;mysql_file_name.rpm&quot; Similarly you can also install the MySQL client and MySQL development RPMs if you've downloaded them. Alternatively, you can install the RPMs through GnoRPM (found under System).
  • 5. You can check your configuration using the following command #netstat -tap Output Looks like below tcp 0 0 *:mysql *:* LISTEN 4997/mysqld MySQL comes with no root password as default. This is a huge security risk. You’ll need to set one. So that the local computer gets root access as well, you’ll need to set a password for that too. The local-machine-name is the name of the KonaLink1KonaLink1computer you’re working on. For more information see here #mysqladmin -u root password your-new-password #mysqladmin -h root@local-machine-name -u root -p password your-new-password #/etc/init.d/mysql restart
  • 6. 4. Now we'll set a password for the root user. Issue the following at the prompt. mysqladmin -u root password mysqldata where mysqldata is the password for the root. (Change this to anything you like). 5. It is now time to test the programs. Typing the following at the prompt starts the mysql client program. mysql -u root -p The system asks for the the password. Type the root password (mysqldata). If you don't get the prompt for password, it might be because MySQL Server is not running. To start the server, change to /etc/rc.d/init.d/ directory and issue the command ./mysql start (or mysql start depending on the value of the PATH variable on your system). Now invoke mysql client program.
  • 7. 6. Once MySQL client is running, you should get the mysql> prompt. Type the following at this prompt: show databases; 7. You should now get a display similar to: +----------------+ | Database | +----------------+ | mysql | | test | +----------------+ 2 rows in set (0.00 sec)
  • 8.
  • 9. Frequently this registration process is done by the editing of a special application-specific configuration file either via a Web GUI or from the command line. Read your application's installation guide for details. You should always remember that MySQL is just a database that your application will use to store information. The application may be written in a variety of languages with Perl and PHP being the most popular. The base PHP and Perl RPMs are installed with Fedora Linux by default, but the packages used by these languages to talk to MySQL are not. You should also ensure that you install the RPMs listed in Table 34.1 on your MySQL clients to ensure compatibility. Use the yum utility discussed in Chapter 6, &quot; Installing Linux Software &quot;, if you are uncertain of the prerequisite RPMs needed.
  • 10.
  • 11. SQL Constraints Constraints are used to limit the type of data that can go into a table. Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement). We will focus on the following constraints: * NOT NULL * UNIQUE * PRIMARY KEY * FOREIGN KEY * CHECK * DEFAULT
  • 12. BASIC MySQL COMMAND * CREATE TABLE syntax * DROP TABLE syntax * DELETE syntax * SELECT syntax * JOIN syntax * INSERT syntax * REPLACE syntax * UPDATE syntax
  • 13. BASIC QURIES CREATE TABLE This command is used to create structure of the table. Syntax : Create table <tablename>(list of col Definition1,....); Example: Create table emp1 (Emp ID (number(3) primary key, Name(varchar(20), Age(number(), DOB(date));
  • 14. DROP TABLE Syntax: Drop table [if exists] tbl_name Explanation: DROP TABLE removes one or more tables. All table data and the table definition are removed.You can use the keywords IF EXISTS to prevent an error from occurring for tables that don't exist.
  • 15. DELETE Syntax: Delete from <tablename>; Example: Delete from emp1; Explanation: This command is used to delete the rows and column.
  • 16. SELECT Syntax: Select * from <tablename>; Example: Select * from emp1; Explanation: This command is used to describe the structure of the table.
  • 17. INSERT VALUE Syntax: Insert into <tablename> values (list of values); Example: Insert into emp1 values (11, Anu, 20,30-aug-1989); Explanation: This command is used to insert values into the structure of the table.
  • 18. REPLACE Syntax: REPLACE [INTO] tbl_name [(col_name,...)] VALUES (expression,...) Explanation: REPLACE works exactly like INSERT, except that if an old record in the table has the same value as a new record on a unique index, the old record is deleted before the new record is inserted.
  • 19. UPDATE Syntax: UPDATE [table] SET [column]=[value] WHERE [criteria] UPDATE Used_Vehicles SET mileage=66000 WHERE vehicle_id=1; UPDATE [table] SET [column]=[value] WHERE [criteria] Example: UPDATE Used_Vehicles SET mileage=66000 WHERE vehicle_id=1; Explanation: UPDATE updates columns in existing table rows with new values. The SET clause indicates which columns to modify and the values they should be given. The WHERE clause, if given, specifies which rows should be updated. Otherwise all rows are updated.
  • 20.
  • 21. AS Syntax: SELECT <columns>FROM <existing_table_name>AS <new_table_name> Example: SELECT t1.name -> FROM artists -> AS t1; Explanation: It is used to create a shorthand reference to elements with long names to make the SQL statements shorter and reduce the chance of typos in the longer names.
  • 22. ALTERING THE DATABASE STRUCTURE AND ADDING DATA Syntax: ALATER TABLE tablename ADD clm_name type Example: ALTER TABLE cds -> ADD producerID INT(3);
  • 23. UNION JOINS Syntax: Select <fields>from <table> where <condition> union SELECT <fields> FROM <table>WHERE <condition> Example: SELECT artist FROM artists WHERE (artists.name LIKE 'P%') UNION SELECT artists.name FROM artists WHERE (artists.name LIKE 'G%'); Explanation: Union Joins allow the results of two queries to be combined into one outputted result set. This is done by having the 2 (or more) queries glued together by the UNION operator.
  • 24. CREATING THE TEMPORARY TABLE Definition: The syntax for creating temporary tables is almost identical that used for creating a normal table. Except that there is an extra TEMPORARY clause. Syntax: CREATE TEMPORARY TABLE <table> (field definition) CREATE TEMPORARY TABLE <newtable>SELECT * FROM <oldtable>
  • 25. TRUNCATE TABLE Syntax: TRUNCATE TABLE <table_name> Example: TRUNCATE TABLE emp1;
  • 26. TRUNCATE( ) Syntax: TRUNCATE(X,D) Use: This function is used to return the value of X truncated to D number of decimal places.
  • 27. INSERT( ) Syntax: INSERT(str,pos,len,newstr) Use: Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr.
  • 28. The UPDATE Statement The UPDATE statement is used to update existing records in a table. SQL UPDATE Syntax UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value
  • 29. The DELETE Statement The DELETE statement is used to delete rows in a table. SQL DELETE Syntax DELETE FROM table_name WHERE some_column=some_value
  • 30. To export a database, use the mysqldump utility normally located in your mysql/bin directory . For example, to export all the tables and data for a database named guestdb. Syntax: mysqldump guestdb > guestdb.txt Exporting a Database
  • 31. This will create a text file containing all the commands necessary to recreate all the tables and data found in guestdb. However, what if I want to export only one table? To do this the command is modified as follows assuming guestTbl is the table to be exported. Syntax: mysqldump guestdb guestTbl > guestdb.txt
  • 32. With the data in a text file, its time to import the data back into MySQL. This can be done by passing the commands contained in the text file into the MySQL client. For example: mysql -p --user=username < guestdb.txt This passes all the commands in the file into the mysql client just like you were typing them in. Importing the Database