"MySQL Command Line Client"里要怎么操作?

hjx000 2005-10-18 04:04:55
新安装了MySQL,创建了test数据库,但不知道如何在“MySQL Command Line Client”下进行操作,比如,查询数据库里有哪些表等等。。。
...全文
2102 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
mathematician 2005-10-19
  • 打赏
  • 举报
回复
SHOW DATABASES;
hjx000 2005-10-18
  • 打赏
  • 举报
回复
如何查看mysql里都有哪些数据库,如何看数据库名称?
loveflea 2005-10-18
  • 打赏
  • 举报
回复
1、mysql4.1及以上版本用group_concat函数实现,sql server一般用一个自定义函数实现

mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t |
| tmp1 |
+----------------+
2 rows in set (0.31 sec)

mysql> create table t1(no int not null,name varchar(10));
Query OK, 0 rows affected (0.51 sec)

mysql> insert into t1 values
-> (1,'a'),(1,'b'),(1,'c'),(1,'d'),(2,'a'),(2,'b'),(2,'c'),(3,'d');
Query OK, 8 rows affected (0.13 sec)
Records: 8 Duplicates: 0 Warnings: 0

mysql> select * from t1;
+----+------+
| no | name |
+----+------+
| 1 | a |
| 1 | b |
| 1 | c |
| 1 | d |
| 2 | a |
| 2 | b |
| 2 | c |
| 3 | d |
+----+------+
8 rows in set (0.16 sec)

mysql> select no,group_concat(name separator ' ') from t1 group by no;
+----+----------------------------------+
| no | group_concat(name separator ' ') |
+----+----------------------------------+
| 1 | a b c d |
| 2 | a b c |
| 3 | d |
+----+----------------------------------+
3 rows in set (1.36 sec)
loveflea 2005-10-18
  • 打赏
  • 举报
回复
多看看使用手册

D:\mysql50\bin>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 5.0.13-rc-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> show tables from test;
+----------------+
| Tables_in_test |
+----------------+
| t |
| tmp1 |
+----------------+
2 rows in set (2.51 sec)

mysql> desc test.t;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| s1 | int(11) | NO | PRI | 0 | |
+-------+---------+------+-----+---------+-------+
1 row in set (2.72 sec)

mysql> select @@version;
+--------------+
| @@version |
+--------------+
| 5.0.13-rc-nt |
+--------------+
1 row in set (0.23 sec)
hy2003fly 2005-10-18
  • 打赏
  • 举报
回复
你登录后,是不是出现一个下面命令提示符呀?
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23 to server version: 4.1.12-nt-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
你就直接在下边写SQL语句,然后以分号结束,按Enter.
mysql> use mysql;
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
| user_info |
+---------------------------+
16 rows in set (0.01 sec)

还有就是:select,update,alter命令,你自己去找一下啦.


56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧