After creating a database and a table, we first think of inputting data into the database table. Next we will discuss how to add data to the database:
1. The common method is insert statements.
Reference content is as follows: Insert into tablename values (value1, value2 ,...) Insert into tablename (fieldname1, fieldname2,...) values (value1, value2 ,...) Insert into tablename set fieldname1 = value1, Fieldname2 = value2 ,... Insert into tablename (fieldname1, fieldname2) select fieldname1, Fieldname2 from tablename1 |
In addition, we can use the insert statement to insert several rows into a table at the same time.
Reference content is as follows: Insert into tablename values (...),(...),... |
2. in the MySQL environment, we can also use the load data statement to read the DATA in the file into the table. generally, this file is directly read by the server on the host. therefore, you must have the file permission and the file must be fully readable. if your version is new enough, you can provide a local file. As you read the file from the client and transmit the content to the server, you do not need the file permission.
If you do not provide a local address, the server locates it as follows:
(1) If your filename is an absolute path, the server will start searching for the file from the root directory.
(2) If your filename is a relative path, the server will start searching for the file from the database data directory.
If you provide local, the file will be located as follows:
(1) If your filename is an absolute path, the client will start searching for the file from the root directory.
(2) If your filename is a relative path, the client will start searching for the file from the current directory.
Specific format:
Reference content is as follows: Load data [LOCAL] INFILE 'filename' Into table tablename import_options [(Fieldname_list)] |
The import options syntax is:
Reference content is as follows: Fields Terminated by 'Char' Enclosed by 'Char' Escaped by 'Char' Lines Terminated by 'string' |
- 2 pages in total:
- Previous Page
- 1
- 2
- Next Page