共計 1645 個字符,預計需要花費 5 分鐘才能閱讀完成。
自動寫代碼機器人,免費開通
這篇文章將為大家詳細講解有關怎么使用 navicat 進行 mysql 命令行操作,丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
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 命令行操作就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
向 AI 問一下細節