Data Manipulation Language(DML)

SQL supports the following statements for manipulating data:

  • INSERT

  • SELECT... INTO

  • LOAD DATA ...

  • UPDATE (Planing)

  • DELETE (Planing)

  • MERGE(Planing)

INSERT

INSERT INFO tbl_name [(column_list)] VALUES (value_list) [,(value_list)]...

column_list:
    col_name [, col_name] ...

value_list:
    value [, value] ...

Description:

INSERT statement inserts new rows into an existing table.

Examples:

SELECT ... INTO

Options
Type
Default

delimiter

String

,

header

Boolean

true

null_value

String

null

format

String

csv

mode

String

error_if_exists

Description:

The SELECT ... INTO form of SELECT enables a query result to be written to a file:

  • SELECT ... INTO OUTFILE writes the selected rows to a file. Column and line terminators can be specified inoptions to produce a specific output format.

Examples:

Write data from table t1 to a file data.csv with fields terminated by ',':

Write data from table t2 to a file data2.csv with fields terminated by '|' and null value represented by 'NA':

LOAD DATA

Options
Type
Default

delimiter

String

,

header

Boolean

true

null_value

String

null

format

String

csv

Description:

The LOAD DATA statement reads rows from a text file into a table at a very high speed.

LOAD DATA is the complement of SELECT...INTO OUTFILE. (See [SELECT ... INTO](#SELECT ... INTO).)

  • To write data from a table to a file, use SELECT...INTO OUTFILE.

  • To read the file back into a table, use LOAD DATA

Examples:

Read rows from data.csv back into table demo_table1 with fields terminated by ',':

Read rows from data2.csv back into table demo_table2 with fields terminated by '|' and null_value represented by "NA":

Last updated