1.mysql 如何对desc等产生的结果集进行查询。2.如果将show variables的结果集写入文件中?3.mysql DO 语法。这个看文档没看明白它到底是干什么的。。4.mysql HANDLER,这个是不是只能打开有索引的表? 5.谢谢回答 。

解决方案 »

  1.   

    1.可以从information_schema找到你想要的结果2.重定向到文件
     %mysqladmin variables>a.txt3.你最好能提出问题4.不是
      

  2.   

    如果是在应用程序中,则 desc tablename 可以当作普通的SELECT对待,即可读取结果集。mysql_query("desc table1");mysql -uroot -p1234 mysql -e "show variables;" > xxxx.datDO executes the expressions but does not return any results. In most respects, DO is shorthand for SELECT expr, ..., but has the advantage that it is slightly faster when you do not care about the result. 
    DO 执行表达式,但不返回任何结果。 应该不是,无索引也可以打开。
      

  3.   

    1.desc test.t; #和下面的语句差不多哈!您可以替换的
      select * from information_schema.columns where `TABLE_SCHEMA`='test' and `TABLE_NAME`='t';2.mysql命令行执行tee output.txt;show variables;exit 然后查看output.txt文件
    如果将show variables的结果集写入文件中? 3.相当于select 但不返回结果 如 do @result:=1+1;4.不是 5.不客气 。
      

  4.   


     #4楼 loveflea(coolwind)   已经给了你 3. 的例子了。mysql> set @x=1;
    Query OK, 0 rows affected (0.00 sec)mysql> select @x:=5;
    +-------+
    | @x:=5 |
    +-------+
    |     5 |
    +-------+
    1 row in set (0.00 sec)mysql> do @x:=10;    
    Query OK, 0 rows affected (0.00 sec)
    -- DO 无返回,但下面可以看到@x  已被更新mysql> select @x; 
    +------+
    | @x   |
    +------+
    |   10 |
    +------+
    1 row in set (0.00 sec)mysql>
      

  5.   


     -- 创建一个无索引的表
    mysql> create table t_joejoe1991 (id int) engine=myisam;
    Query OK, 0 rows affected (0.06 sec)mysql> insert into t_joejoe1991 values
        -> (1),
        -> (2),
        -> (6),
        -> (3),
        -> (2),
        -> (8),
        -> (4);
    Query OK, 7 rows affected (0.00 sec)
    Records: 7  Duplicates: 0  Warnings: 0-- 仅在此验证一下,表的输出顺序。 :-) 另一个贴子中有人问过。
    mysql> select * from t_joejoe1991;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    |    6 |
    |    3 |
    |    2 |
    |    8 |
    |    4 |
    +------+
    7 rows in set (0.00 sec) -- 用hander 打开这个无索引的表
    mysql> HANDLER t_joejoe1991 OPEN ;
    Query OK, 0 rows affected (0.00 sec)mysql> HANDLER t_joejoe1991 READ FIRST ;
    +------+
    | id   |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)mysql> HANDLER t_joejoe1991 READ NEXT  ;
    +------+
    | id   |
    +------+
    |    2 |
    +------+
    1 row in set (0.00 sec)mysql> HANDLER t_joejoe1991 READ NEXT  ;
    +------+
    | id   |
    +------+
    |    6 |
    +------+
    1 row in set (0.00 sec)mysql> HANDLER t_joejoe1991 READ NEXT  ;
    +------+
    | id   |
    +------+
    |    3 |
    +------+
    1 row in set (0.00 sec)mysql> HANDLER t_joejoe1991 READ NEXT  ;
    +------+
    | id   |
    +------+
    |    2 |
    +------+
    1 row in set (0.00 sec)mysql> HANDLER t_joejoe1991 CLOSE;
    Query OK, 0 rows affected (0.00 sec)mysql>