mysql基础

发布时间 2023-08-06 22:43:43作者: yezheng

数据库:

show databases; 显示本地数据库

select database();查询当前使用的数据库

use information_schema;选择使用哪个数据库

create database mydb 新建数据库

drop database mydb 删除数据库

表:

use mydb;

show tables;查看该数据库中多少表

describe chengji 查看表结构

drop table chengji 删除表

 

Select查询:
database()

version()

user()数据库用户名

@@version_compile_os 操作系统版本

now() 当前时间

(4*4/10)+1 计算

@@datadir 数据库路径

例1:
use dvwa;

select * from users where user_id=3;(查询表中具体数据)

select * from users where user_id='3'

select * form users order by 4;(判断表的字段(列属性))

 

Union操作符

用于合并多个selecct查询语句的结合集(注:union内部的select查询的是相同的列)

例2:

use dvwa;

select first_name,last_name from users union select user_name,password from users;(都是两列)

 

字符串连接(select .......)

concat(str1,str2....) j将多个字符串连接成一个字符串

例3:select concat(user_id,'_',first_name) from users;

concat_ws(seperator,str1,str2....) 第一个参数指定分隔符

group_concat() 同一个分组中的值连接起来,返回一个字符串

 

Insert操作(相应的列填表)

insert into users(first_name,last_name) values('Ye','Zheng');

 

Update(更新操作)

update users set user='yezheng',password='123456' where user_id='yezheng'

 

Delete操作

delete from users where user='yezheng'

 

13.5.0.7770系统词频: 630211129编译时间: Jun  2 2023 20:15:10