mysql 基本入門語句

2021-09-20 03:55:25 字數 1157 閱讀 3633

mysql -u username -ppassword            資料庫連線

show databases          查所有庫

use  庫名          選庫

create database  資料庫名          建立乙個資料庫

drop   database          刪除乙個資料庫

show tables          查所有表

create 表名          建表

drop 表名         刪除表

rename table 舊名 to 新名         改表名

alter table 舊名 rename 新名   改表名

truncate  表名         清空表資料

tee 路徑          把之後敲的內容及結果都輸入至這個路徑下的檔案

desc 表名         檢視表結構

\q  +回車         退出資料庫

insert into 表名 values (值1,值2....)          將數值依次插入所有列,列與值必須一一對應

insert into 表名(列名1,列名2....) values (值1,值2....)

insert into 表名(列名1,列名2....) values (值1,值2....), values (值7,值8....)           

一次可插入多行資料,用 「,」隔開

update 表名 set  列1=新值1,列2=新值2  where 表示式

delete from  表名 where 表示式

select * from  表名          查詢所有行和列

select 列名1,列名2   from  表名        查詢部分列,所有行

select 列名1,列名2   from  表名  where 表示式

select  distinct  列名1,列名2   from  表名        去重查詢,篩選並顯示出表中不同的資料,去掉重複的行。

select    列名1,列名2   from  表名  where 列名 like  '%關鍵字%'    

例:select name,dis from city where dis like '%的%';

mysql學習 基本入門語句

檢視所有資料庫 show databases 建立庫 create database 庫名 刪除庫 drop database 庫名 選擇庫 use 庫名 選擇某個資料庫後檢視該庫的所有表 show tables 在該庫中建立乙個表 create table 表名 id int sname varc...

mysql基本語句 mysql基本語句

mysql關係型資料庫rds中的老大哥,增刪改查是mysql入門的基礎 增刪改查語句 增刪改查的語句命令為 增 insert 刪 delete 改 update 查 select或者show 庫操作建立資料庫 create database shujukuba 建立帶字符集的資料庫 create d...

MySql (二)入門語句和基本操作

mysql的入門語句 檢視伺服器下的庫 show databases 建立庫 資料庫被建立後它的名字是不可以更改的 create database 資料庫名 2.1.插看當前所在的庫 select database 刪除庫drop database 資料庫名 drop database if exi...