Database administrator can input data into database table using SQL statements. In this lab, we will be using the tables created in the previous lab (
Lab 2) as example in showing the insert data. The tables created previously is shown in Figure 1 below.
|
Figure 1: Show tables in the previous lab exercise. |
The SQL command to insert a data into a particular table is shown below:
Figure 2 shows how to insert the data shown in the table below into the table
"123456_lecturer".
|
Table 1: Data for lecturer "Ms. Inson Din". |
|
Figure 2: Syntax to insert data from table 1 |
Using the similar SQL command, a user can choose to enter partial data into a particular table. Figure 3 shows the metadata of table "
students".
|
Figure 3: metadeta of table "students". |
However, the insert operation shown in Figure 4 below shows that only 3 column of data were entered into the system without the column "
stdemail".
|
Figure 4: Insert data into tables with data from specific column only. |
This operation to only fill partial columns in a data can be achieved by only selecting the specific column to be entered in the first line of the SQL statements, and only fill in the column accordingly in the second SQL line.