INTO
INTO is a keyword in SQL that is used to insert new data into a database table. It specifies the table where the inserted rows should go. This keyword is primarily employed in the INSERT INTO statement.
Example
Output
Explanation
The above example demonstrates the use of the INTO
keyword in SQL, specifically MySQL. A new table, test_table
, is first created with two columns, number
and name
. Then, two rows of data are inserted using the INSERT INTO
statement. The SELECT * FROM
statement is used to display all rows from test_table
.
Example
Output
Explanation
The example query duplicates an existing table named ‘OldTable’ and creates a new table named ‘NewTable’ with the same data structure and values - only for records that satisfy the given ‘Condition’. The result of the command isn’t a data set but a completion notification.
Example
Output
Explanation
In the example, a variable text_var
is declared to store text data. The SELECT INTO
statement retrieves the string ‘Hello, Oracle!’ and assigns it to text_var
. The DBMS_OUTPUT.PUT_LINE
procedure prints the value of text_var
, resulting in the output ‘Hello, Oracle!’. The FROM dual
clause is a Oracle-specific syntax to select from a dummy table.
Example
Output
Explanation
The INSERT INTO
statement is used to insert new records into a table in SQLite. In the example, a new record is created for ‘John Doe’ with age ‘30’ in the ‘Employee’ table.