• mysql基础命令


    mysql数据库使用

    show databases;  #查看所有库
    show global variables like '%datadir%';  #查看库位置  一般默认在/var/lib/mysql下
    use mysql;  #进入mysql库
    select database();  #查看当前在哪个库
    create database aa;  #创建库
    drop database aa;  #删除库
    
    show tables;  #查看库中的表
    create table bb(id int,name varchar(10),lase varchar(10));  #创建表id,name,lase
    drop dable aa,bb  #删除多个表
    describe aa;  desc aa;  #查看表的结构
    show create table aaG  #查看表的属性
    
    alter table aa add phone char(10);  #添加phone列
    alter table aa drop phone;  #删除phone列
    rename table aa to cc;  #修改表名
    
    insert into 表名 (列1,列2,列3,,,) values (值1,值2,值3,,,)  #插入数据
    insert into aa values (值1,值2,值3,,,)  #插入数据
    
    select * from 表名;  #查看表中所有数据
    select id from aa;  #查看表中id列
    select * from aa where id=1;  #查看表中id=1这一列
    select * from aa where id>1 and id<5;  #查看表中id大于1小于5的数据
    
    create table aa as select * from cc;  #把cc表复制且创建aa表。
    insert into cc select * from aa;  # 把aa表数据复制到cc表,cc表是空的。
    
    delete from aa;  #清空表aa
    delete from aa where id=1;  #删除id=1的列数据
    
    update aa set name='123';  #将aa表中的名字都改为123
    update aa set name='123' where id=1;  #将aa表中id=1的名字修改为123
    
    #表连接:有某一个共同的列名
    #一个id和name:aa
    #一个id和sale:bb
    
    select * from aa join bb where aa.id=bb.id  #查看两个表连接
    select name,sela from aa join bb where aa.id=bb.id and name='list';  #查看名字为list的lase
    select * from aa join bb using(id);  #两个表有共同的列
    
  • 相关阅读:
    PHP 载入图像 imagecreatefrom_gif_jpeg_png 系列函数
    PHP 输出图像 imagegif 、imagejpeg 与 imagepng 函数
    php实现等比例不失真缩放上传图片
    PHP开发框架--CodeIgniter(CI)使用总结
    将Centos的yum源更换为国内的阿里云源
    开始投资的活动条件是什么
    复利效应 每天进步一点点到底指的是什么?
    你拥有的最宝贵的财富是什么?
    自律真的可以改变人生
    chpasswd-批量修改用户密码
  • 原文地址:https://www.cnblogs.com/wml3030/p/15380515.html
Copyright © 2020-2023  润新知