Lab Manual 3
Lab Manual 3
In our second lab exercise we have seen basic introduction to MySQL and
we have started to use some MySQL commands .This lab exercise is the
continuation of the second exercise and it will give you more details about
the most important MySQL statements or commands.
1. CREATING TABLES
Syntax: Create table table_name (column 1 data type1 [constraint 1]…
column n data type n [constraint n]) ENGINE= Engine type;
2. DROPPING TABLES
After it is dropped your table no more exists. So create the table child again
using the syntax from example 1above.
We can also use the RENAME Command to change the name of an existing
table into a new one.
Where table_name is the name of the table on which the values are to be
inserted in and V1, V2… Vn are values of the corresponding columns of the
table. Note that string values must be placed inside single quote.
Where table_name is the name of the table on which the values are to be
inserted in, Column 1, Column 2… Column x are the specific columns and V1,
V2… Vx are values of the corresponding columns. Note that string values must
be placed inside single quote.
7. DELETING RECORDS
Syntax: DELETE FROM table_name WHERE condition;
Note: The where condition is very important. Otherwise all your data in the
table will be deleted.
8. UPDATING RECORDS
Syntax: UPDATE table_name SET column_name = new_value WHERE
condition;
Note: The where condition is very important. Otherwise all your data in the
table will be updated.
Exercise: CREATE the following tables. Be careful while selecting the data
types, constraints, primary key(s) and foreign key(s).After creating populate
them with appropriate values.