日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql程序语句范文_MySQL基本语句

發布時間:2024/3/12 数据库 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql程序语句范文_MySQL基本语句 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、查看當前使用的是哪個數據庫

mysql> select database();

另外,在下面2個語句的輸出里也能看出當前庫是哪一個

mysql> show tables;

mysql> status;

2、查看MySQL版本和狀態

mysql> select VERSION();

mysql> status;

3、查看MySQL實例的當前狀態(參數形式)

mysql> show status;

4、查看MySQL實例的參數

mysql> show variables;

查看最大連接數

mysql> show variables like ‘%max_connections%‘;

5、查看MySQL實例當前的進程

mysql> show processlist;

6、查詢所有數據

select * from Info 查所有數據

select Code,Name from Info 查特定列

7、根據條件查

select * from Info where Code=‘p001‘ 一個條件查詢

select * from Info where Code=‘p001‘ and Natio n=‘n001‘ 多條件 并關系 查詢

select * from Info where Name=‘胡軍‘ or Nation=‘n001‘ 多條件 或關系 查詢

select * from Car where Price>=50 and Price<=60 范圍查詢

select * from Car where Price between 50 and 60 范圍查詢

8、模糊查詢

select * from Car where Name like ‘%型‘ %通配符代表任意多個字符

select * from Car where Name like ‘%奧迪%‘

select * from Car where Name like ‘_馬%‘?_通配符代表任意一個字符

9、排序

select * from Car order by Price asc 按照價格升序排列

select * from Car order by Price desc 按照價格降序排列

select * from Car order by Price,Oil 按照兩列進行排序,前面的為主要的

10、統計函數(聚合函數)

select count(Code) from Car 查詢表中有多少條數據

select max(Price) from Car 取價格的最大值

select min(Price) from Car 取價格的最小值

select sum(Price) from Car 取價格的總和

select avg(Price) from Car 取價格的平均值

11、分組查詢

select Brand from Car group by Brand having count(*)>2 查詢所有系列中數量大于2的

12、分頁查詢

select * from Car limit 0,5 跳過幾條數據取幾條數據

13、去重查詢

select distinct Brand from Car

14、查詢建庫、建表語句

mysql> show create database dbname;

指定庫后才能查詢建表語句

mysql> show create table tablename;

15、查詢指定表的字段屬性

mysql> show full columns from tablename;

或者

mysql> show full fields from tablename;

總結

以上是生活随笔為你收集整理的mysql程序语句范文_MySQL基本语句的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。