Practical 16 - MySQL Basic Commands
Practical 16 - MySQL Basic Commands
AIM
To create a database called college which will contain a table called teachers. To
perform the following commands -
create database / table(with constraints) - To create a new database / table
insert - To insert records into the table specified.
select(with various clauses and conditions) - To retrieve records from table
where Clause - test a condition and filter rows on the basis of the conditions.
like - The job of this operator is to look for a specified pattern in a column. This
operator uses wildcard characters % and _ (underscore) . The % sign matches to
zero or more characters whereas the _ (underscore) matches to exact one
character.
distinct Clause–To get a non-repeating set of values for an attribute.
count() – It is a simple function that counts the rows of a table or entries in a
column.
SQL Commands Execution
mysql> create database college;
Database changed
->tnamevarchar(30),
-> );
+-------+--------------------+------+-----------+--------+--------+
+-------+--------------------+------+-----------+--------+--------+
+-------+--------------------+------+-----------+--------+--------+
+-------+--------------------+------+----------+--------+--------+
+-------+--------------------+------+----------+--------+--------+
+-------+--------------------+------+----------+--------+--------+
+--------------------+------+
| tname | dept |
+--------------------+------+
| Saurabh Srivastav | IT |
+--------------------+------+
+-------+--------------------+------+----------+--------+--------+
+-------+--------------------+------+----------+--------+--------+
+-------+--------------------+------+----------+--------+--------+
mysql> select * from teachers where salary >= 30000 and salary <= 70000;
+-------+------------+------+----------+--------+--------+
+-------+------------+------+----------+--------+--------+
+-------+------------+------+----------+--------+--------+