0% found this document useful (0 votes)
3 views5 pages

SQL Table Creation and Data Insertion

The document outlines the creation of two SQL tables: 'professor' and 'teaches', including the insertion of several records into each table. It also presents two employee tables, 'Employees' and 'EmployeeUNI', detailing their structure and sample data. Additionally, it discusses the use of ROUND and CAST functions in SQL for numeric precision control.

Uploaded by

pre123gil.123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

SQL Table Creation and Data Insertion

The document outlines the creation of two SQL tables: 'professor' and 'teaches', including the insertion of several records into each table. It also presents two employee tables, 'Employees' and 'EmployeeUNI', detailing their structure and sample data. Additionally, it discusses the use of ROUND and CAST functions in SQL for numeric precision control.

Uploaded by

pre123gil.123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CREATE TABLE professor(

INSERT INTO professor VALUES (1, 'Rohan', 57000);


ID int,
INSERT INTO professor VALUES (2, 'Aryan', 45000);
Name varchar(20),
INSERT INTO professor VALUES (3, 'Arpit', 60000);
Salary int
INSERT INTO professor VALUES (4, 'Harsh', 50000);
);
INSERT INTO professor VALUES (5, 'Tara', 55000);

CREATE TABLE teaches(


INSERT INTO teaches VALUES (1, 1, 'English');
course_id int,
INSERT INTO teaches VALUES (1, 3, 'Physics');
prof_id int,
INSERT INTO teaches VALUES (2, 4, 'Chemistry');
course_name varchar(20)
INSERT INTO teaches VALUES (2, 5, 'Mathematics');
);

Employees table: EmployeeUNI table:


+----+----------+ +----+-----------+
| id | name | | id | unique_id |
+----+----------+ +----+-----------+
| 1 | Alice | | 3 | 1 |
| 7 | Bob | | 11 | 2 |
| 11 | Meir | | 90 | 3 |
| 90 | Winston | +----+-----------+
| 3 | Jonathan |
+----+----------+
Employees table: EmployeeUNI table:
+----+----------+ +----+-----------+
| id | name | | id | unique_id |
+----+----------+ +----+-----------+
| 1 | Alice | | 3 | 1 |
| 7 | Bob | | 11 | 2 |
| 11 | Meir | | 90 | 3 |
| 90 | Winston | +----+-----------+
| 3 | Jonathan |
+----+----------+
ROUND(numeric, integer) is. Explicitly casting to NUMERIC resolves the mismatch.

CAST(... AS NUMERIC) is flexible for operations requiring precision control.

You might also like