As a qualified tester to the database of single-table query, multi-table query, group query, sub-query, and so on these basic query methods still will. Otherwise to the enterprise, easy to be despised by some people, or if the database is not good, the table does not understand, then to their ability is also an insult, because you can prove yourself, you can, especially when you face the interview at the interview with the interviewer to give you a question of SQL statement, You can immediately use your routine to make this problem, so congratulations on your first small level. OK, let's learn the first query in the database today, and also the simplest and easiest way to get started looking at----single-table queries.
We created a ClassInfo and Studentinfo table in the previous article, both of which have no data. As shown in the following:
We're looking at the Studentinfo watch.
SELECT * from ClassInfo; --SQL for querying the class table
SELECT * from Studentinfo; --SQL for querying student tables
So we're going to insert data into the table, there are two more common ways to insert the data, let's look at the first method, and see the correct use posture of the INSERT INTO keyword. We first insert the following data into the ClassInfo table: 01, Test 1 class 02, Test 2 Class 03, test 3 classes, 04 Test 4 class (when inserting data, be sure to pay attention to the type and constraints of inserting data, do not violate our constraints when creating the table, specifically, you can see my previous introduction---Oracle Created Table operation), so that you can continue to watch the show:
Insert into ClassInfo (classid,classname) VALUES ( on,'Test a class') insert into ClassInfo (classid,classname) VALUES ( Geneva,'Test Class II') insert into ClassInfo (classid,classname) VALUES (Geneva,'Test Class three') insert into ClassInfo (classid,classname) VALUES (Geneva,'Test Class Four'); commit;--commit is a one-time commit to the database save, no commit will not be really stored in the database. --rollback is a rollback operation, which means that you can roll back to the last operation without a commit
We inserted 4 data into the ClassInfo table and looked at SQL parsing:
INSERT INTO---SQL keyword for inserting tables
ClassInfo---The name of the table in which the data is inserted
CLASSID, classname---column names in the table
Values---SQL keyword for inserting data
Let's take a look at the insert results, after the insert run is complete, you need a SELECT * from ClassInfo this table to see if there is any success. Such as:
Perfect, insert completed, insert successful, if we commit to the database, we need a commit, or just temporary creation success, not really saved to the database. Then we went on to insert some data into the Studentinfo table to see the show:
INSERT INTO Studentinfo (studentid,studentname,studentsex,studentage,studenttel,studentaddress) VALUES ( ' Zhang Shan ', ' male ', ' 13789895566',' Beijing '); Select from Studentinfo;
Oracle Database Single Table query