Page 250 - PYTHON-12
P. 250
A keyword refers to an individual SQL element that has a special meaning in SQL. For example,
SELECT and FROM are keywords. A clause is a distinct logical part of an SQL statement. Clauses
begin with a keyword for which they are named and consist of arguments as well. For example.
SELECT empno, ename, FROM employee WHERE salary>45000, are clauses in SQL. Here, arguments
complete or modify the meaning of a clause, which is salary in the given example.
A statement or command is a combination of two or more clauses. Statements are basically the
instructions given to SQL database for executing any task. For example, SELECT * FROM employee is
an SQL statement. An important point to remember here is that all the statements in SQL terminate
with a semi-colon (;). Also, SQL is not case sensitive; therefore, we can type commands in either
upper case or lower case.
Let us now learn how a database and tables in a database are created in SQL. A database is used
to house data in the form of tables. Therefore, before creating a table, it is mandatory to create a
database first.
We shall create a sample database School and then create a table Student in it.
Database: School
Tables_in_School
Student
Fees
Table: Student Table: Fees
Rollno Name Gender Marks DOB Rollno Name Fees
1 Raj Kumar M 93 17-Nov-2000 1. Raj Kumar 8000
2 Deep Singh M 98 22-Aug-1996 2. Deep Singh 9000
3 Ankit Sharma M 76 02-Feb-2000 5. Payal Goel 7500
4 Radhika Gupta F 78 03-Dec-1999 6. Diksha Sharma 8000
5 Payal Goel F 82 21-April-1998 9. Shreya Anand 8020
6 Diksha Sharma F 80 17-Dec-1999 10. Prateek Mittal 9200
7 Gurpreet Kaur F 65 04-Jan-2000
8 Akshay Dureja M 90 05-May-1997
9 Shreya Anand F 70 08-Oct-1999
10 Prateek Mittal M 75 25-Dec-2000
To get started on our own database, we can first check which databases currently exist in MySQL
server. Use the SHOW DATABASES statement to find out which databases currently exist on the
server:
mysql> show databases;
Computer Science with Python–XII 12.20 +---------------+
+---------------+
| Database |
| mysql |
| test |
+---------------+
2 rows in set (0.01 sec)