zoukankan      html  css  js  c++  java
  • 数据库日常操作命令基础

    常用数据库类型

    TINYINT(n)   8位整数类型
    SMALLINT(n)    16位整数类型
    MEDIUMINT(n)   32位整数类型
    INT(n)         32位整数类型
    BIGINT(n)      64位整数类型
    FLOAT(n,d)     单精度浮点数
    DOUBLE(n,d)    双精度浮点数
    DATE           日期格式
    char           固定长度字符串
    varchar        非固定长度字符串
    BIT            二进制数据
    BLOB           非定长二进制数据

    常用属性如下:
    NOT NULL           要求数据为非空值
    AUTO_INCREMENT     用户插入新的数据后对应整数数据列自动加1
    PRIMARY KEY        创建主索引
    KEY                普通索引
    DEFAULT CARSET     设置默认字符集
    ENGINE             设置默认数据库存储引擎
    character set utf8 collate utf_bin


    数据库定义语言
    1.create  创建
    2.alter   修改属性

    alter database wang default character set=utf8;
    alter database wang default collate=utf8_general_ci;  修改数据库默认字符集
    alter table boss rename boss1;                        表改名
    alter table employees add date timestamp;             添加时间类型列
    alter table employees add note char(50);
    alter table employees add index (date);               默认添加索引
    alter table employees add primary key (employee_id);  设置主键
    alter table employees drop column note;               删除字段

    drop
    rename

    数据库操作语言

    1.insert
    2.update
    3.load data infile 快速从文本中读取数据到数据表中
        load data infile '/tmp/txt' into table wang.employees;
    4.delete 将满足条件的数据记录删除

    数据库查询语言
    select AVG(score)from test  查询test表中score列数据的平均值
    select count(employee_id)from test  统计有多少条employee_id,显示最终个数
    select distinct(employee_email)from test 如果有多条employee_email相同的则去重
    select first_name from employees where last="willian" 查询first_name并且满足条件last="willian"
    select from employees order by hire_date desc  查询表中所有记录并按照hire_date排序 降序  AES为升序
    select from employees limit 2; 显示数据记录中的前两行

    We are down, but not beaten. tested but not defeated.
  • 相关阅读:
    Delphi WebService连接数据库
    编写一个单独的Web Service for Delphi7(步骤)
    Delphi stdCall意义
    Delphi WEB APP DEBUGGER是如何使用的
    用delphi的THTTPRIO控件调用了c#写的webservice。
    Delphi 编写的Web Service
    Delphi WebService 中 Web App Debugger 的建议
    flex布局浅谈和实例
    IOS开关效果
    文字渐变和边框渐变
  • 原文地址:https://www.cnblogs.com/guniang/p/6650891.html
Copyright © 2011-2022 走看看