Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
826 views
in Technique[技术] by (71.8m points)

mysql - Format SQL Table data as Text Table

I have a result from Oracle database as below:

1   Chi Phí L??ng   FA_Phan_Bo_Chi_Phi_Luong    8   JOHN    8   2015    (BLOB)  FA_Phan_Bo_Chi_Phi_Luong_Final.csv  09-NOV-15   ?? Hoàn Thành
2   T?ng H?p TimeSheet Nhan Viên    FA_Tong_Hop_Timesheet   8   JOHN    8   2015    (BLOB)  FA_Tong_Hop_Timesheet_COM_Final.csv 09-NOV-15   ?? Hoàn Thành
3   T?ng H?p Doanh Thu  FA_Tong_Hop_Doanh_Thu   8   JOHN    8   2015    (BLOB)  FA_Tong_Hop_Doanh_Thu_Final.csv 09-NOV-15   ?? Hoàn Thành
4   Chi Phí Ho?t ??ng C?ng Ty   FA_CP_Hoat_Dong 8   JOHN    8   2015    (BLOB)  FA_CP_Hoat_Dong_Final.csv   09-NOV-15   ?? Hoàn Thành
5   Kh?u Hao Máy Móc Thi?t B?   FA_CP_Khau_Hao_Phan_Bo_MMTB 8   JOHN    8   2015    (BLOB)  FA_CP_Khau_Hao_Phan_Bo_MMTB_Final.csv   09-NOV-15   ?? Hoàn Thành

How can I format text as a table with the same width of column?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your text sql result:

+---+------------------------------+-----------------------------+---+------+---+------+--------+---------------------------------------+-----------+---------------+
| 1 | Chi Phí L??ng                | FA_Phan_Bo_Chi_Phi_Luong    | 8 | JOHN | 8 | 2015 | (BLOB) | FA_Phan_Bo_Chi_Phi_Luong_Final.csv    | 09-NOV-15 | ?? Hoàn Thành |
+---+------------------------------+-----------------------------+---+------+---+------+--------+---------------------------------------+-----------+---------------+
| 2 | T?ng H?p TimeSheet Nhan Viên | FA_Tong_Hop_Timesheet       | 8 | JOHN | 8 | 2015 | (BLOB) | FA_Tong_Hop_Timesheet_COM_Final.csv   | 09-NOV-15 | ?? Hoàn Thành |
+---+------------------------------+-----------------------------+---+------+---+------+--------+---------------------------------------+-----------+---------------+
| 3 | T?ng H?p Doanh Thu           | FA_Tong_Hop_Doanh_Thu       | 8 | JOHN | 8 | 2015 | (BLOB) | FA_Tong_Hop_Doanh_Thu_Final.csv       | 09-NOV-15 | ?? Hoàn Thành |
+---+------------------------------+-----------------------------+---+------+---+------+--------+---------------------------------------+-----------+---------------+
| 4 | Chi Phí Ho?t ??ng C?ng Ty    | FA_CP_Hoat_Dong             | 8 | JOHN | 8 | 2015 | (BLOB) | FA_CP_Hoat_Dong_Final.csv             | 09-NOV-15 | ?? Hoàn Thành |
+---+------------------------------+-----------------------------+---+------+---+------+--------+---------------------------------------+-----------+---------------+
| 5 | Kh?u Hao Máy Móc Thi?t B?    | FA_CP_Khau_Hao_Phan_Bo_MMTB | 8 | JOHN | 8 | 2015 | (BLOB) | FA_CP_Khau_Hao_Phan_Bo_MMTB_Final.csv | 09-NOV-15 | ?? Hoàn Thành |
+---+------------------------------+-----------------------------+---+------+---+------+--------+---------------------------------------+-----------+---------------+

You can generate text tables at tablesgenerator like following formats.

You can give input as:

  1. SQL result in File -> Paste Table Data
  2. File -> Import CSV File
  3. Or you can generate table manually

Here you can align column values to left, right, centre.

Without Using Unicode symbols for table borders

+----+-------------+--------+-------+-----+
| id | name        | gender | state | age |
+----+-------------+--------+-------+-----+
| 1  | John Kenedy | male   | NY    | 32  |
+----+-------------+--------+-------+-----+
| 2  | Meresa Oslo | female | HI    | 26  |
+----+-------------+--------+-------+-----+
| 3  | Mike Lanes  | male   | FL    | 25  |
+----+-------------+--------+-------+-----+

Useing Unicode symbols for table borders

╔════╦═════════════╦════════╦═══════╦═════╗
║ id ║ name        ║ gender ║ state ║ age ║
╠════╬═════════════╬════════╬═══════╬═════╣
║ 1  ║ John Kenedy ║ male   ║ NY    ║ 32  ║
╠════╬═════════════╬════════╬═══════╬═════╣
║ 2  ║ Meresa Oslo ║ female ║ HI    ║ 26  ║
╠════╬═════════════╬════════╬═══════╬═════╣
║ 3  ║ Mike Lanes  ║ male   ║ FL    ║ 25  ║
╚════╩═════════════╩════════╩═══════╩═════╝

Markdown table

| id | name        | gender | state | age |
|----|-------------|--------|-------|-----|
| 1  | John Kenedy | male   | NY    | 32  |
| 2  | Meresa Oslo | female | HI    | 26  |
| 3  | Mike Lanes  | male   | FL    | 25  |

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...