Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
The Language of SQL- P39:Research has shown that, being pressed for time, most readers tend to skip the introduction of any book they happen to read and then proceed immediately to the first real chapter. With that fact firmly in mind, we will only cover relatively unimportant material in the introduction, such as an explanation of what you will and will not learn by reading this book. | 176 Chapter 17 Modifying Data DATABASE DIFFERENCES Oracle Oracle doesn t permit multiple rows to be specified after the values keyword. The previous example would need to be broken down into two statements such as INSERT INTO Customers FirstName LastName State VALUES Virginia Jones OH INSERT INTO Customers FirstName LastName State VALUES Clark Woodland CA Also note that the order of values after the VALUES keyword corresponds to the order of columns listed in the columnlist after the INSERT TO. The order in which the columns are listed does not have to be the same as it is in the database. In other words the above insert just as easily could have been accomplished with this statement INSERT INTO Customers State LastName FirstName VALUES OH Jones Virginia CA Woodland Clark In the above INSERT we listed the State column first instead of last. Again the order in which columns are listed doesn t matter. To sum up the general format for the INSERT INTO statement is INSERT INTO table columnlist VALUES RowValuesl RowValues2 repeat any number of times The columns in columnlist need to correspond to the columns in RowValues. Also if all the columns in columnlist are listed in the same order as they physically exist in the database and if there are no auto-increment columns in the Inserting Data 177 table then the INSERT INTO statement can be executed without specifying the columnlist. However this practice is strongly discouraged since it is prone to error. What happens when not all columns are specified in an INSERT Simple. Those columns that are not specified are given NULL values. For example let s say we want to insert one additional row into the Customers table for a customer named Tom Monroe. However we don t know Tom s state. Here s the INSERT INSERT INTO Customers FirstName LastName VALUES Tom Monroe Afterwards his row in the table appears as CustomerID FirstName LastName State 6 Tom Monroe NULL Since we didn t specify a value for the State column for this new row .