mysql常用命令學習03

2021-10-08 10:17:16 字數 1617 閱讀 2168

(1)登入

//   mysql –h 主機名 –u使用者名稱 –p密碼c:

/> mysql -h 192.168

.1.45

-u root -p root

(2)顯示所有資料庫

mysql > show databases;
(3)進入指定的資料庫

//  	use 庫名;

mysql > use mysql;

(4)檢視庫中所有表

//show tables from 庫名;檢視其他庫中的所有表

mysql > show tables;

mysql > show tables from mysql;

(5)檢視當前庫

mysql > select database()

;

(6)檢視版本

c:/

> mysql -version //進入mysql客戶端之前c:

/> mysql -

v//進入mysql客戶端之前

mysql > select version()

;//進入mysql客戶端之後

(7)新建乙個資料庫

mysql > create database spark;
(8)建表

mysql > create table customer

(id varchar(30

),age int, name varchar(30

),birthday date)

;

(9)檢視表結構

mysql > desc customer;
(10)檢視表

mysql > select *

from customer;

(11)查詢特定列

mysql > select id,name,*** from student
(12)查詢資料並進行過濾

mysql > select id,name,*** from student where id =>

1003

;

(13)運算子查詢

//查詢年紀在18到35之間的學生的id、名字、性別

mysql > select id,name,*** from student where age >=

18 and age <=35;

mysql > select id,name,*** from student where age between 18 and 35

;

(14)查詢變種

mysql > select *

from student where age =

18 or age =

35 or age =

23;

mysql學習 常用命令

檢視當前所有的資料庫show databases 開啟某個資料庫use 庫名 檢視當前庫的所有表show tables 檢視其他庫的所有表show tables from 庫名 建立表create table 表名 列名 列型別,列名 列型別 檢視表結構desc 表名 檢視伺服器版本 方法一 在my...

Linux常用命令03

上篇我們寫到,如何編輯檔案,我們有時候,在編輯的時候,有可能會異常的退出,這樣的話,linux會針對這個檔案生成乙個swp檔案,當你下次進入vi模式時,就會提示你乙個錯誤 這樣,即使你按enter鍵,進入到檔案,然後編輯檔案,當你再次進入vi模式時,你還是發現這個提示還是存在,怎麼去掉 這個提示內,...

mysql基本常用命令 MySQL常用命令(一)

cmd提示框中的mysql基礎命令 一 命令 連線mysql伺服器 mysql h localhost u root p 展示所有資料庫 show databases 選擇資料庫 use database 展示所選資料下所有表 show tables 設定資料庫編碼 set names gbk 用s...