My sql

726 views
649 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
726
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
31
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

My sql

  1. 1. MySQL Is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. 1.Basic Queries 2.Porcedures and Functions 3.Imports and Exports
  2. 2. Basic Query Commands in MySQL CREATE Command SELECT Command DELETE Command INSERT Command UPDATE Command DROP Command
  3. 3. CREATE Command The Create command is used to create a table by specifying the tablename, fieldnames and constraints as shown below : Syntax : $createSQL=("CREATE TABLE tblName");
  4. 4. SELECT Command The Select command is used to select the records from a table using its field names. To select all the fields in a table, '*' is used in the command. The result is assigned to a variable name as shown below: Syntax: $selectSQL=("SELECT field_names FROM tablename");
  5. 5. DELETE Command The Delete command is used to delete the records from a table using conditions as shown below: Syntax: $deleteSQL=("DELETE * FROM tablename WHERE condition");
  6. 6. INSERT Command The Insert command is used to insert records into a table. The values are assigned to the field names as shown below: Syntax: $insertSQL=("INSERT INTO tblname(fieldname1,fieldname2..) VALUES(value1,value2,...) ");
  7. 7. UPDATE Command The Update command is used to update the field values using conditions. This is done using 'SET' and the fieldnames to assign new values to them. Syntax: $updateSQL=("UPDATE Tblname SET (fieldname1=value1,fieldname2=value2,...) WHERE fldstudid=IdNumber"); .
  8. 8. DROP Command The Drop command is used to delete all the records in a table using the table name as shown below: Syntax: $dropSQL=("DROP tblName");
  9. 9. PROCEDURE AND FUNCTIONS Procedures The procedure is a program that performs an action and does not return a value (outside of IN OUT and OUT parameters). Functions The function is a program that might perform an action and does return a value.
  10. 10. A procedure is declared as: CREATE OR REPLACE PROCEDURE() AS BEGIN END; Procedure Syntax
  11. 11. Functions Syntax A function is declared as : CREATE OR REPLACE FUNCTION() RETURN AS BEGIN RETURN END;
  12. 12. It can be used to back up a database or to move database information from one server to another. It can be used to back up a database or to move database information from one server to another. It can be used to back up a database or to move database information from one server to another. IMPORT AND EXPORT
  13. 13. This example shows  how to export a database. It is a good idea to export the data often as a backup. # mysqldump -u username -ppassword database_name > FILE.sql Replace username, password and database_name with your MySQL username, password and database name. 1.Export A MySQL Database:
  14. 14. Here, we import a database. Using this to restore data from a backup or to import from another MySQL server. Start by uploading the FILE.sql file to the server where we will be running this command. # mysql -u username -ppassword database_name < FILE.sql 2. Import A MySQL Database:

×