...
Code Block | ||||
---|---|---|---|---|
| ||||
delete_from_tag_where_stmt ::= 'DELETE FROM' table_name 'WHERE' tag_name '=' value ( and tag_time '<' datetime_expression )? |
Tag 테이블은 아래와 같이 2가지 방식의 삭제 쿼리가 추가적으로 지원된다.
...
The Tag table additionally supports two types of deletion queries as follows.
- Delete by tag name
- Delete by tag name and tag time
Code Block | ||
---|---|---|
| ||
-- Delete by tag name 기준 삭제 DELETE FROM tag where tag_name = 'my_tag_2021' -- Delete by tag name 와and tag time 기준 삭제 DELETE FROM tag where tag_name = 'my_tag_2021' and tag_time < TO_DATE('2021-07-01', 'YYYY-MM-DD'); |
- 삭제 쿼리가 실행된 후에, 삭제된 row가 저장공간에서 물리적으로 삭제되기 까지 걸리는 시간은, DBMS의 동작상황에 따라서 다를 수 있다The time it takes for the deleted row to be physically deleted from the storage space after the deletion query is executed may vary depending on the situation of the DBMS.
LOAD DATA INFILE
...
load_data_infile_stmt:
...
Code Block | ||||
---|---|---|---|---|
| ||||
load_data_infile_stmt: 'LOAD DATA INFILE' file_name 'INTO TABLE' table_name ( 'TABLESPACE' tbs_name )? ( 'AUTO' ( 'BULKLOAD' | 'HEADUSE' | 'HEADUSE_ESCAPE' ) )? ( ( 'FIELDS' | 'COLUMNS' ) ( 'TERMINATED BY' char )? ( 'ENCLOSED BY' char )? )? ( 'TRIM' ( 'ON' | 'OFF' ) )? ( 'IGNORE' number ( 'LINES' | 'ROWS' ) )? ( 'MAX_LINE_LENGTH' number )? ( 'ENCODED BY' coding_name )? ( 'ON ERROR' ( 'STOP' | 'IGNORE' ) )? |
CSV 포맷의 데이터 파일을 서버에서 직접 읽어서, 옵션에 따라 서버에서 직접 테이블 및 컬럼들을 생성하여 이를 입력하는 기능이다.
각 옵션에 대해서 설명하면 다음과 같다.
...
옵션
...
format data files are read directly from the server, and tables and columns are created directly from the server according to the options and input them.
Each option is explained as follows
Options | Description |
---|---|
AUTO mode_string mode_string = (BULKLOAD | HEADUSE | HEADUSE_ESCAPE) |
해당 테이블을 생성하고 컬럼 타입(자동 생성시 varchar type) 및 컬럼명을 자동으로 생성한다.
BULKLOAD: 데이터 한 개의 row를 하나의 컬럼으로 입력한다. 컬럼으로 구분할 수 없는 데이터에 대해서 사용한다.
Creates the corresponding table and automatically generates the column type (varchar type for automatic creation) and the column name. |
option, but appends a '_' character to the front and back of the column name to avoid errors that can occur if the column name is the same as the reserved word in the DB. If a special character exists in the column name, changes it to '_'. |
(FIELDS|COLUMNS) TERMINATED BY 'term_char' ESCAPED BY 'escape_char' |
Specifies the delimiter (term_char) |
and escape character (escape_char) |
for parsing the data line. For common CSV files, the delimiter is , and the escape character is '. |
ENCODED BY coding_name coding_name = { UTF8(default) | MS949 | KSC5601 | EUCJP | SHIFTJIS | BIG5 | GB231280 } |
Specifies the encoding options for the data file. The default value is UTF-8. |
TRIM (ON | OFF) |
Removes or maintains the empty space of the column. The default is ON. |
IGNORE number (LINES | ROWS) |
Ignores data for a specified number of lines or lines. It is used to ignore header of CSV format file or ignore VCF header. |
MAX_LINE_LENGTH |
Specifies the maximum length of one line. The default value is 512K. If the data is larger, you can specify a larger value. |
ON ERROR (STOP | IGNORE) |
입력 도중 에러가 발생할 경우 수행할 동작을 지정한다. STOP인 경우 입력을 중단하고 IGNORE인 경우 에러가 발생한 라인을 건너뛰고 계속 입력한다.
Specifies the action to take when an error occurs during input. If it is STOP, input is stopped. If it is IGNORE, the line where error occurred is skipped and input is continued. |
Code Block | ||||
---|---|---|---|---|
| ||||
-- Use default field delimiter(,) field encloser (") 를to 사용하여input 데이터를 입력한다data. LOAD DATA INFILE '/tmp/aaa.csv' INTO TABLE Sample_data ; -- Create NEWTABLE 하나의with 컬럼을one 갖는column NEWTABLE을and 생성해서enter 한one 라인을line 한as 컬럼으로one 입력한다column. LOAD DATA INFILE '/tmp/bbb.csv' INTO TABLE NEWTABLE AUTO BULKLOAD; -- Create csv의NEWTABLE using 첫번째first 라인을line 컬럼of 정보로csv 이용하여as NEWTABLE을column 생성하고information, and 이를input 그it 테이블에into 입력한다table. LOAD DATA INFILE '/tmp/bbb.csv' INTO TABLE NEWTABLE AUTO HEADUSE; -- 첫번째 라인은 무시하고 필드 구분자는 ; First line is ignored and field delimiter is ; and enclosing 문자는character 'is 로specified 지정해서by 입력한다'. LOAD DATA INFILE '/tmp/ccc.csv' INTO TABLE Sample_data FIELDS TERMINATED BY ';' ENCLOSED BY '\'' IGNORE 1 LINES ON ERROR IGNORE; |
Tip |
---|
AUTO 옵션을 사용하지 않는 경우 테이블의 모든 컬럼은 VARCHAR 또는 TEXT 타입으로 생성해야 한다If the AUTO option is not used, all columns of the table must be created as VARCHAR or TEXT types. |