如何使用navicat进行mysql命令行 *** 作?

如何使用navicat进行mysql命令行 *** 作?,第1张

如何使用navicat进行mysql命令行 *** 作?

下面介绍如何使用Navicat进行mysql命令行 *** 作的具体 *** 作方法。

推荐教程:MySQL数据库入门教程

1、打开Navicat

2、点击【工具】菜单,选择【命令列界面】

3、此时进入了mysql命令行状态

扩展资料:MySQL基本 *** 作命令

数据库 *** 作

显示所有的数据库

mysql> show databases;(注意:最后有个 s)

创建数据库

mysql> create database test;

连接数据库

mysql> use test;

查看当前使用的数据库

mysql> select database();

当前数据库包含的表信息

mysql> show tables; (注意:最后有个 s)

删除数据库

mysql> drop database test;

表 *** 作

备注: *** 作之前使用“use <数据库名>”应连接某个数据库。

建表

命令:create table <表名> (<字段名 1> <类型 1> [,..<字段名 n> <类型 n>]);

例子:

mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));

获取表结构

命令: desc 表名,或者show columns from 表名

例子:

mysql> describe MyClass
mysql> desc MyClass;
mysql> show columns from MyClass;

删除表

命令:drop table <表名>

例如:删除表名为 MyClass 的表

mysql> drop table MyClass;

插入数据

命令:insert into <表名> [( <字段名 1>[,..<字段名 n > ])] values ( 值 1 )[, ( 值 n )]

例子:

mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);

查询表中的数据

查询所有行

mysql> select * from MyClass;

查询前几行数据

例如:查看表 MyClass 中前 2 行数据

mysql> select * from MyClass order by id limit 0,2;

或者

mysql> select * from MyClass limit 0,2;

删除表中数据

命令:delete from 表名 where 表达式

例如:删除表 MyClass 中编号为 1 的记录

mysql> delete from MyClass where id=1;

修改表中数据

命令:update 表名 set 字段=新值,... where 条件

mysql> update MyClass set name='Mary' where id=1;

在表中增加字段

命令:alter table 表名 add 字段 类型 其他;

例如:在表 MyClass 中添加了一个字段 passtest,类型为 int(4),默认值为 0

mysql> alter table MyClass add passtest int(4) default '0'

更改表名

命令:rename table 原表名 to 新表名;

例如:在表 MyClass 名字更改为 YouClass

mysql> rename table MyClass to YouClass;

更新字段内容

命令:update 表名 set 字段名 = 新内容

update 表名 set 字段名 = replace(字段名, '旧内容', '新内容');

例如:文章前面加入 4 个空格

update article set content=concat('    ', content);

以上就是如何使用navicat进行mysql命令行 *** 作?的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/706671.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-24
下一篇 2022-04-24

发表评论

登录后才能评论

评论列表(0条)

保存