我有一個涉及MySQL的問題。這個問題可以看出,在這兩個圖像:MySQL表格沒有正確對齊
http://imgur.com/NrOwSxS,yPo9Cra http://imgur.com/NrOwSxS,yPo9Cra#1
有誰知道爲什麼MySQL是這樣做呢?它應該顯示爲一張漂亮整潔的桌子,而不是這些亂碼。提前致謝! :d
我有一個涉及MySQL的問題。這個問題可以看出,在這兩個圖像:MySQL表格沒有正確對齊
http://imgur.com/NrOwSxS,yPo9Cra http://imgur.com/NrOwSxS,yPo9Cra#1
有誰知道爲什麼MySQL是這樣做呢?它應該顯示爲一張漂亮整潔的桌子,而不是這些亂碼。提前致謝! :d
首先,證明沒有什麼真的錯了,嘗試此查詢:
SELECT firstname FROM contact_info
這應該很好看。現在試試這個:
SELECT firstname, lastname FROM contact_info
這就是你如何挑選單個列。
真的要捕捉輸出到一個文件,該頁面顯示您如何:The MySQL Command-Line Tool
然後你就可以學會使用其他程序很好地格式化。
我假設你創建你的表有點像這樣:
create table automobile (make char(10),model char(10),year int, color char(10), style char(50), MSRP int);
insert into automobile values ('Ford','Mustang',2006,'Blue','Convertible',27000);
insert into automobile values ('Toyota','Prius',2005,'Silver','Hybrid',22000);
insert into automobile values ('Toyota','Camry',2006,'Blue','Sedan',26000);
insert into automobile values ('Dodge','1500',2005,'Green','Pickup',26000);
所以
describe automobile
會顯示您的列:
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| make | char(10) | YES | | NULL | |
| model | char(10) | YES | | NULL | |
| year | int(11) | YES | | NULL | |
| color | char(10) | YES | | NULL | |
| style | char(50) | YES | | NULL | |
| MSRP | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
只要你列總數小於您的終端寬度,您應該看到 預期結果:
mysql> select * from automobile;
+--------+---------+------+--------+-------------+-------+
| make | model | year | color | style | MSRP |
+--------+---------+------+--------+-------------+-------+
| Ford | Mustang | 2006 | Blue | Convertible | 27000 |
| Toyota | Prius | 2005 | Silver | Hybrid | 22000 |
| Toyota | Camry | 2006 | Blue | Sedan | 26000 |
| Dodge | 1500 | 2005 | Green | Pickup | 28000 |
+--------+---------+------+--------+-------------+-------+
如果您想讓結果更小,然後選擇您想要查看的列,
select make,model from automobile
mysql> select make,model from automobile;
+--------+---------+
| make | model |
+--------+---------+
| Ford | Mustang |
| Toyota | Prius |
| Toyota | Camry |
| Dodge | 1500 |
+--------+---------+
,使一列的含量少,你可以使用左字符串函數
select left(make,4) as make, left(model,5) as model,left(style,5) as style from automobile;
+------+-------+-------+
| make | model | style |
+------+-------+-------+
| Ford | Musta | Conve |
| Toyo | Prius | Hybri |
| Toyo | Camry | Sedan |
| Dodg | 1500 | Picku |
+------+-------+-------+
也許你可以試試'SELECT * FROM contact_info \ G' – 2013-03-18 03:59:47
這不是MySQL,但是你的終端其實是 – zerkms 2013-03-18 04:00:29
有無論如何解決它? 我希望它看起來像這張表: http://imgur.com/1zP6uVX – 2013-03-18 04:04:02