syntax structure: INSERT into table name (column name 1, column Name 2 ...) Values (value 1, value 2 ...)
Code Demo:
Sql> INSERT into Infos VALUES (①
2 ' s100102 ', ' lin ', ' Male ', 22, 2,
3 to_date (' 2009-8-9 06:30:10 ', ' yyyy-mm-dd HH24:MI:SS '), ②
4, default, ' 1001 ' ③
5);
Code parsing:
The ① table name is followed by the default column name, which defaults to all column names, and the value in values corresponds to the order of the columns in the table and the data type one by one.
In Sql*plus a statement can be written on multiple lines, and from the second line, Sqlplus will give the travel number to the front of each line.
② in Oracle, dates are internationalized, different regional installations of the database, the default date format is different, so for the program to be portable,
Date input to use the To_date function to format the date and format the date with a formatted string.
Characters in a formatted string are not case-sensitive, and common formatting characters are as follows:
The YYYY represents a four-digit year, the MM represents a two-digit month, the DD represents a date, and the hh24 represents an hour from 1-23;hh12 also represents the hour from 0-11;
Mi means minutes; SS represents seconds
③ You can use the default value instead when you encounter a column that has the defaults.
In Oracle, an INSERT command inserts a result set into a single table at once.
The statements used are: INSERT into table SELECT clause
Code Demo: Insert inserts a result set into a table
In this syntax, the data type of each column in the result set is required to conform to the data type of each column in the table, and the number of columns in the result set is the same as the number of columns in the table.
Oracle Data Insertion