Adding Multiple Rows to a Table
SQL>
SQL> CREATE TABLE Student (
2 StudentID INT NOT NULL PRIMARY KEY,
3 Name VARCHAR(50) NOT NULL);
Table created.
SQL>
SQL> INSERT INTO Student (StudentID,Name) VALUES (1,'Tom');
1 row created.
SQL> INSERT INTO Student (StudentID,Name) VALUES (2,'Jack');
1 row created.
SQL> INSERT INTO Student (StudentID,Name) VALUES (3,'Mary');
1 row created.
SQL> INSERT INTO Student (StudentID,Name) VALUES (4,'Bill');
1 row created.
SQL> INSERT INTO Student (StudentID,Name) VALUES (5,'Cat');
1 row created.
SQL>
SQL>
SQL> CREATE TABLE Professor (
2 ProfessorID INT NOT NULL PRIMARY KEY,
3 Name VARCHAR(50) NOT NULL);
Table created.
SQL>
SQL>
SQL> INSERT INTO Professor (ProfessorID, Name)
2 SELECT StudentID + 7, Name
3 FROM Student;
5 rows created.
SQL>
SQL> drop table Professor;
Table dropped.
SQL> drop table Student;
Table dropped.
Related examples in the same category