溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

怎么使用navicat進(jìn)行mysql命令行操作

發(fā)布時間:2020-12-21 11:10:10 來源:億速云 閱讀:648 作者:小新 欄目:數(shù)據(jù)庫

這篇文章將為大家詳細(xì)講解有關(guān)怎么使用navicat進(jìn)行mysql命令行操作,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

1、打開Navicat

怎么使用navicat進(jìn)行mysql命令行操作

2、點擊【工具】菜單,選擇【命令列界面】

怎么使用navicat進(jìn)行mysql命令行操作

3、此時進(jìn)入了mysql命令行狀態(tài)

怎么使用navicat進(jìn)行mysql命令行操作

擴(kuò)展資料:MySQL基本操作命令

數(shù)據(jù)庫操作

顯示所有的數(shù)據(jù)庫

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

創(chuàng)建數(shù)據(jù)庫

mysql> create database test;

連接數(shù)據(jù)庫

mysql> use test;

查看當(dāng)前使用的數(shù)據(jù)庫

mysql> select database();

當(dāng)前數(shù)據(jù)庫包含的表信息

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

刪除數(shù)據(jù)庫

mysql> drop database test;

表操作

備注:操作之前使用“use <數(shù)據(jù)庫名>”應(yīng)連接某個數(shù)據(jù)庫。

建表

命令: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));

獲取表結(jié)構(gòu)

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

例子:

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

刪除表

命令:drop table <表名>

例如:刪除表名為 MyClass 的表

mysql> drop table MyClass;

插入數(shù)據(jù)

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

例子:

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

查詢表中的數(shù)據(jù)

查詢所有行

mysql> select * from MyClass;

查詢前幾行數(shù)據(jù)

例如:查看表 MyClass 中前 2 行數(shù)據(jù)

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

或者

mysql> select * from MyClass limit 0,2;

刪除表中數(shù)據(jù)

命令:delete from 表名 where 表達(dá)式

例如:刪除表 MyClass 中編號為 1 的記錄

mysql> delete from MyClass where id=1;

修改表中數(shù)據(jù)

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

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

在表中增加字段

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

例如:在表 MyClass 中添加了一個字段 passtest,類型為 int(4),默認(rèn)值為 0

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

更改表名

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

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

mysql> rename table MyClass to YouClass;

更新字段內(nèi)容

命令:update 表名 set 字段名 = 新內(nèi)容

update 表名 set 字段名 = replace(字段名, '舊內(nèi)容', '新內(nèi)容');

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

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

關(guān)于怎么使用navicat進(jìn)行mysql命令行操作就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI