菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
292
0

sql基础

原创
05/13 14:22
阅读数 47812

1、mysql基础命令

查看数据库:show databases;

查看数据库中的表:show tables;

显示表结构:description或者DESC users;

查看记录:select user,password from users where user_id=1;

2、 information_schema

  • TABLE_SCHEMA:数据库名

  • TABLE_NAME:表名

 

 

2.1 TABLES表

 

显示所有信息:select * from information_schema ;
查询数据库:select DISTINCT TABLE_SCHEMA from information_schema.TABLES ;
查询数据库和数据表:select TABLE_SCHEMA ,GROUP_CONCAT(TABLE_NAME) from information_schema.tables group by TABLE_SCHEMA \G
显示数据表:select TABLE_NAME from information_schema.tables where TABLE_SCHEMA='dvwa' ;

2.2 columns表

column_name:字段名

查询所有列:select * from information_schema.columns\G

查询某个库的某个表:select column_name from information_schema.columns where TABLE_SCHEMA ='dvwa' and TABLE_NAME ='users';

查询某个表:select column_name from information_schema.columns where TABLE_NAME ='SCHEMA_PRIVILEGES';

显示数据库的信息:select first_name,last_name from users where user_id =1 union select version(),database()
select first_name,last_name from users where user_id =1 union select user(),database();

 

发表评论

0/200
292 点赞
0 评论
收藏