将语法从sqlplus格式更改为mysql格式

时间:2012-07-05 16:18:22

标签: mysql sqlplus

我目前正在尝试将语法从sqlplus更改为mysql以设置报告文件的外观,以便更有条理

set pagesize 66
set linesize 75
ttitle center EarthOrientation Parameters(U) 2                                       

column year heading "Year" format 9999
column month heading "Month" format 99
column day heading "Day" format 99
column mjd heading "MJD" format 99999
select year, month , day , mjd, from     TB_PARAMETER_UI order by year,month,day,mjd; */

有没有人知道正确替换setpage大小和设置行大小和tittle以及如何在mysql中设置列?

1 个答案:

答案 0 :(得分:0)

在Oracle中你可以设置一下,在Mysql中我没有听说过类似的东西,但你可以使用它:

select LEFT(`text`,100) as columname from table1;

其中100是字符数,但如果您想以其他格式显示结果,可以使用\G代替;

修改

mysql> select left(first_name,4) as short_name from t1 limit 10;
+------------+
| short_name |
+------------+
| PENE       |
| NICK       |
| ED         |
| JENN       |
| JOHN       |
| BETT       |
| GRAC       |
| MATT       |
| JOE        |
| CHRI       |
+------------+
10 rows in set (0.00 sec)

编辑2:

mysql> select left(first_name,4) as short_name 
from t1 limit 10 into outfile 'test.txt';
Query OK, 10 rows affected (0.00 sec)

编辑3:

试试这个:

mysql -e "select left(first_name,4) as short_name 
from t1 limit 10" -u myuser -pxxxxxxxxx mydatabase > mydumpfile.txt

它给出了这样的结果:

short_name
PENE
NICK
ED
JENN
JOHN
BETT
GRAC
MATT
JOE
CHRI