温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么使用navicat进行mysql命令行操作

发布时间:2020-12-21 11:10:10 来源:亿速云 阅读:618 作者:小新 栏目:数据库

这篇文章将为大家详细讲解有关怎么使用navicat进行mysql命令行操作,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

1、打开Navicat

怎么使用navicat进行mysql命令行操作

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

怎么使用navicat进行mysql命令行操作

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

怎么使用navicat进行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命令行操作就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI