programing

테이블 형식 없이 SQL 쿼리 결과 가져오기

luckcodes 2023. 1. 1. 12:18

테이블 형식 없이 SQL 쿼리 결과 가져오기

예를 들면--disable-column-names옵션, 테이블 형식 없이 SQL 쿼리를 가져올 수 있는 옵션이 있습니까?예를 들어 다음과 같습니다.

mysql -u username -p password  --disable-column-names --execute "select name from test"

다음 결과:

-----
| A |
| B |
| C |
| D |
-----

형식 없이 아래와 같은 sql 프로그램 옵션 수식자를 사용하여 조회 결과를 얻을 수 있습니까?

나는 이것을 원한다:

A
B
C
D

를 추가합니다.-B에 깃발을 올리다.mysql.

mysql -B -u username -ppassword \
    --disable-column-names \
    --execute "select name from mydb.test"
-B, --batch: Print results in nontabular output format.

--execute: Execute the statement and quit.

주의:-B/--batch또, 이네이블로 하겠습니다--silent전환합니다.

다른 응답은 부수적으로 동작하지만 올바른 스위치는-s의 줄임말인--silent.

추가 지정이 필요할 수 있습니다.-r위해서--raw출력은 문자 이스케이프도 디세블로 합니다.그렇지 않으면 newline, tab, null char 및 backslash는 각각 \n, \t, \0 및 \로 표시됩니다.

   ·   --silent, -s

       Silent mode. Produce less output. This option can be given multiple
       times to produce less and less output.

       This option results in nontabular output format and escaping of
       special characters. Escaping may be disabled by using raw mode; see
       the description for the --raw option.

   ·   --raw, -r

       For tabular output, the “boxing” around columns enables one column
       value to be distinguished from another. For nontabular output (such
       as is produced in batch mode or when the --batch or --silent option
       is given), special characters are escaped in the output so they can
       be identified easily. Newline, tab, NUL, and backslash are written
       as \n, \t, \0, and \\. The --raw option disables this character
       escaping.

       The following example demonstrates tabular versus nontabular output
       and the use of raw mode to disable escaping:

           % mysql
           mysql> SELECT CHAR(92);
           +----------+
           | CHAR(92) |
           +----------+
           | \        |
           +----------+
           % mysql -s
           mysql> SELECT CHAR(92);
           CHAR(92)
           \\
           % mysql -s -r
           mysql> SELECT CHAR(92);
           CHAR(92)
           \

- Oracle Corporation

MySQL 5.7 06/07/2018

언급URL : https://stackoverflow.com/questions/16711598/get-the-sql-query-result-without-the-table-format