zoukankan      html  css  js  c++  java
  • mysql常见命令?

    查看多少库存在?

    show databases;

    建库:
    create database yintao;
     
    查看 
    show databases;
     
    使用库
    use yintao;
     
    建表
    create table students(
        id int unsigned not null auto_increment primary key,
        name char(8) not null,
        sex char(4) not null,
        age tinyint unsigned not null,
        tel char(13) null default "-"
    );
     
    查看
    show tables;
    desc students;
     
    增 insert
    insert [into] 表名 [(列名1, 列名2, 列名3, ...)] values (值1, 值2, 值3, ...);
    insert into students values(NULL, "王刚", "男", 20, "13811371377");
    insert into students (name, sex, age) values("孙丽华", "女", 21);
     
    删 delete
    delete from 表名称 where 删除条件;
    delete from students;
    delete from students where id=2;
    delete from students where age<20;
     
    改 update
    update 表名称 set 列名称=新值 where 更新条件;
    update students set tel=default where id=5;
    update students set age=age+1;
    update students set name="张伟鹏", age=19 where tel="13288097888";
     
    查 select
    select 列名称 from 表名称 [查询条件];
    select name, age from students;
    select * from students;
     
    select * from students where age > 21;
    select * from students where name like "%王%";
    select * from students where id<5 and age>20;
  • 相关阅读:
    数据库之事务与常见故障
    数学的魅力 之 正多边形
    html5 的基础理解1
    android 引入开源项目
    android 图片查看器
    java 线程安全
    python3 自动生成requirement.txt
    centos 7 安装 python3.7
    python3 创建,激活虚拟环境
    Mac 配置poetry
  • 原文地址:https://www.cnblogs.com/sunyang-001/p/10827517.html
Copyright © 2011-2022 走看看