数据库实际查询操作回顾(一)

   回顾之前学习数据库的相关操作,复习时顺便记录下,以便以后自己可以再次查看!!!

(1)show databases;  //查看所有数据库

(2)show tables;    //返回当前选择的数据库内所有已建立的表格。

(3)show columns from customers;// 它对每个字段返回一行,行中包含字段名、数据 类型、是否允许NULL、键信息、默认值以及其他信息

(4)describe customers;//它对每个字段返回一行,行中包含字段名、数据 类型、是否允许NULL、键信息、默认值以及其他信息

(5)show create database hugh;//用来显示创建数据库时使用的MySQL语句


(6)show create table customers;//用来显示创建该表时使用的MySQL语句

(7)show grants;//用来显示授予用户(所有用户或特定用户)的安 全权限


/*

检索语句

*/

扫描二维码关注公众号,回复: 1859133 查看本文章


(8)select prod_name from products;//返回了prod_name列的所有信息

(9)select prod_id,prod_name,prod_price
from products;//检索多列,中间用“,”隔开

(9)select * from products;//检索所有列时使用该搜索语句最方便

(10)select vend_id
from products;//检索出了vend_id的所有行

(11)select distinct vend_id
from products;//使用distinct关键字就是只返回不同的值,重复的值就只取一个

(12)select prod_name
from products
limit 5;//返回从第一行开始数,到第五行;显示prod_name列的前面五行

(13)select prod_name
from products
limit 5,5;//返回从行5开始的5行。从列prod_name中的第六行开始显示。

(14)select products.prod_name
from products;//使用完全限定列名

(15)select products.prod_name
from hugh.products;//使用完全限定表名,前提表products在数据库hugh中


数据库实际查询操作回顾(二)

数据库实际查询操作回顾(三)

数据库实际查询操作回顾(四)

数据库实际查询操作回顾(五)

数据库实际查询操作回顾(六)

数据库实际查询操作回顾(七)

数据库实际查询操作回顾(八)

猜你喜欢

转载自blog.csdn.net/mr_police/article/details/80784002