zoukankan      html  css  js  c++  java
  • 数据库操作

    -- 创建数据库:如果数据库存在先删除
    CREATE DATABASE IF NOT EXISTS kiko DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
    
    -- 查询所有数据库
    SHOW DATABASES;
    
    -- 切换数据库
    USE kiko;
    -- 删除表:如果表存在先删除表
    DROP TABLE IF EXISTS `USERS`;
    
    -- 创建表
    CREATE TABLE `USERS`(
      ID        INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '主键 自动增长',
      USERNAME  VARCHAR(32) NOT NULL COMMENT '用户名',
      PASSWORD  VARCHAR(32) NOT NULL COMMENT '密码',
      ISACTIVE  INT(11) DEFAULT 0  COMMENT '状态 0 有效 1 无效',
      CREATED   DATETIME DEFAULT NULL COMMENT '创建日期',
      CREATEBY  VARCHAR(32) NOT NULL DEFAULT 'admin' COMMENT '创建者',
      UPDATED   TIMESTAMP  DEFAULT NULL COMMENT '修改日期',
      UPDATEBY  VARCHAR(32) DEFAULT NULL COMMENT '修改人'
    )ENGINE =INNODB CHARSET=UTF8 COMMENT '用户表';
    
    -- 插入数据
    INSERT INTO kiko.USERS (USERNAME, PASSWORD, ISACTIVE, CREATED, CREATEBY, UPDATED, UPDATEBY) VALUES
    ('KIKO', '123456', 0, sysdate(), 'admin', null, null),
    ('Lucy', '123456', 0, sysdate(), 'admin', null, null),
    ('LILY', '123456', 0, sysdate(), 'admin', null, null),
    ('REYES', '123456', 0, sysdate(), 'admin', null, null),
    ('JON', '123456', 0, sysdate(), 'admin', null, null),
    ('MACK', '123456', 0, sysdate(), 'admin', null, null),
    ('JOJO', '123456', 0, sysdate(), 'admin', null, null),
    ('ALX', '123456', 0, sysdate(), 'admin', null, null),
    ('ROOT', '123456', 0, sysdate(), 'admin', null, null),
    ('JIM', '123456', 0, sysdate(), 'admin', null, null),
    ('JOBS', '123456', 0, sysdate(), 'admin', null, null),
    ('Cici', '123456', 0, sysdate(), 'admin', null, null),
    ('Jason', '123456', 0, sysdate(), 'admin', null, null),
    ('Olivia', '123456', 0, sysdate(), 'admin', null, null),
    ('Mert', '123456', 0, sysdate(), 'admin', null, null),
    ('Mindy', '123456', 0, sysdate(), 'admin', null, null),
    ('Lulu', '123456', 0, sysdate(), 'admin', null, null),
    ('Vivian', '123456', 0, sysdate(), 'admin', null, null),
    ('Alison', '123456', 0, sysdate(), 'admin', null, null),
    ('Sophie', '123456', 0, sysdate(), 'admin', null, null),
    ('Alan', '123456', 0, sysdate(), 'admin', null, null),
    ('Shelley', '123456', 0, sysdate(), 'admin', null, null),
    ('Jean', '123456', 0, sysdate(), 'admin', null, null),
    ('Janice', '123456', 0, sysdate(), 'admin', null, null),
    ('Kimi', '123456', 0, sysdate(), 'admin', null, null),
    ('Baby', '123456', 0, sysdate(), 'admin', null, null),
    ('Super', '123456', 0, sysdate(), 'admin', null, null),
    ('Moto', '123456', 0, sysdate(), 'admin', null, null);
    
    -- 查询数据
    SELECT * FROM USERS;
  • 相关阅读:
    leetcode-409
    leetcode-836
    leetcode-1160
    leetcode-面试题13
    leetcode-695
    go的一些小lib
    leetcode-300
    cookie
    php上传文件
    PHP 文件创建/写入
  • 原文地址:https://www.cnblogs.com/reyes/p/6227873.html
Copyright © 2011-2022 走看看