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. Basic Query Commands in MySQL CREATE Command SELECT Command DELETE Command INSERT Command UPDATE Command DROP Command
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. 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. 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. 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. 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. 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. 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. A procedure is declared as: CREATE OR REPLACE PROCEDURE() AS BEGIN END; Procedure Syntax
11. Functions Syntax A function is declared as : CREATE OR REPLACE FUNCTION() RETURN AS BEGIN RETURN END;
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. 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. 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: