<返回更多

MySQL常用命令

2021-04-08  今日头条  神秘露珠
加入收藏

#登入

C:Program Files (x86)MySQLMySQL Server 5.0bin>mysql -u wu -p

Enter password: **

登入成功后显示如下信息:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 57

Server version: 5.0.41-community-nt MySQL Community Edition (GPL)

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

#查询当前用户

mysql> select user();

+--------------+

| user() |

+--------------+

| wu@localhost |

+--------------+

1 row in set (0.00 sec)

#查询所有用户

mysql> select user,host from mysql.user;

+------+-----------+

| user | host |

+------+-----------+

| wu | |

| root | % |

| root | localhost |

+------+-----------+

3 rows in set (0.00 sec)

#查询建表语句

mysql> show creat table db;

#新建表格

create table MyClass1(

id int(4) not null ,

name char(20) not null,

sex int(4) not null default '0',

degree double(16,2));

#增加数据

insert into MyClass values(1,'Tom',96,2),(2,'Joan',82,2), (3,'Wang', 96,2);

#查看表结构

mysql> desc myclass1;

+--------+--------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+--------+--------------+------+-----+---------+-------+

| id | int(4) | NO | PRI | 0 | |

| name | char(20) | NO | | | |

| sex | int(4) | NO | | 0 | |

| degree | double(16,2) | YES | | NULL | |

+--------+--------------+------+-----+---------+-------+

4 rows in set

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>