zoukankan      html  css  js  c++  java
  • MySQL基本使用

    MySQL数据库:
     引擎:innodb( 支持事务,原子性操作), myisam
     默认:用户root 
     create database "数据库名" default charset utf8;
     
     show databases;
     drop database "数据库"; (删除数据库)
      
     use 数据库名称;
     
     show  tables;
     
     select * from 表名;
     
     select name, age, id from 表名;
     
     mysql 数据库user表
     use mysql;
     select user, host from user;
     
     
     创建用户:
      create user '用户名'@'地址' identified by '密码';
      create user 'user'@'192.168.1.1' identified by '123456';
      create user '用户名'@'192.168.1.%' identified by '密码';
      create user 'user'@'%' identified by '123456';
     授权:
      权限(grant )  人
      grant select, insert,update in db1.t1 to 'alex'@'%';
      grant all privileges on db1.t1 to 'alex'@'%';
      revoke all privileges from db1.t1 to 'alex'@'%';  (删除权限)
      
    操作文件:
     create table "表名"(id int,name char(16)) engine=innodb default charset=utf8;
     create table t1(
      列名 类型 null,
      列名 类型 not null,
      列名 类型 not null auto_increment primary key,
      
      id int not null auto_increment primary key,
      name char(10),
     )engine=innodb default charset=utf8;
     
     select * from "表名";
     
     insert into t1(id,name) values(1,'alex');
     
     清空表:
      delete from 表名;
      truncate table ;
      delete from 表名 where id < 6;
     删除表:
      drop table "表名";
     改:
      update '表名' set age=18 where age=17;
     
     
    数据类型:
     数字:
      tinyint
      int
      bigint
      FLOAT
      DOUBLE
      decimal
     字符串:
      char()速度快 255
      varchar()节省空间 225
      PS:定长的放前面
      text
     时间格式
      DATA 年月日
      TIME 时分秒
      YEAR 年
      DATATIME 年时分秒
      TIMESTAMP
      
     外键:
      create table userinfo(
       uid bigint auto_increment primary key,
       name varchar(32),
       department_id int,
       constraint fk_user_depar foreign key ("department_id",) references department('id')
       constraint fk_xx_ff foreign key ("xx_id",) references XX('id')
      )
      create table department(
       id bigint auto_increment primary key,
       title char(15)
      )engine=innodb default charset=utf8;
    此时此刻,非我莫属
  • 相关阅读:
    命令行解释器(shell)
    TensorFlow经典案例2:实现最近邻算法
    TensorFlow经典案例1:基本操作
    TensorBoard在谷歌浏览器显示找不到网页
    Pandas中的DataFrame.filter()
    【转】保证训练集和测试集取到和数据集中相同比例的类别
    数据分析小实践:统计每个国家存在心理健康问题的平均年龄
    TabActivity 切换Activity界面
    Android获取屏幕实际高度跟显示高度,判断Android设备是否拥有虚拟功能键
    非常简单的XML解析(SAX解析、pull解析)
  • 原文地址:https://www.cnblogs.com/taozhengquan/p/9873875.html
Copyright © 2011-2022 走看看