• mysql常用命令


    显示所有数据库:  
        show databases;
    使用某个数据库:
        use  数据库名;
    显示某个数据库的所有表
        show full tables from mblogs where table_type = 'base table';
    显示数据库编码
        show charset
    创建表单
        create table mblogs. m_linkss(id int(4) not null auto_increment,link_name varchar(60),primary key    (id))engine=myisam charset=utf8 collate=utf8_general_ci
    
    删除表   
        drop table mblogs.m_linkss;
    修改表是指修改表的结构或特性。理论上创建一个表能做到的事情,修改表也能做到。修改表有二三十项修改项,包括增删改字段,增删索引,增删约束,修改表选项等等。举例如下:
    添加字段:
        alter table 表名 add [column] 新字段名 字段类型 [字段属性列表];
    修改字段(并可改名):
        alter table 表名 change [column] 旧字段名 新字段名 新字段类型 [新字段属性列表];
    修改字段(只改属性):
        alter table 表名 modify [column]       字段名 新字段类型 [新字段属性列表];
    修改字段名:灰常灰常抱歉,没有单纯修改字段名这个功能!
    删除字段:
        alter table 表名 drop [column] 字段名;
    添加普通索引:
        alter table 表名 add index [索引名] (字段名1[,字段名2,...]);
    添加主键索引(约束):
        alter table 表名 add primary key (字段名1[,字段名2,...]);
    添加外键索引(约束):
        alter table 表名1 add foreign key (字段1,[,字段名2,...]) references 表名2(字段1,[,字段名2,...]);
    添加唯一索引(约束):
        alter table 表名 add unique (字段名1[,字段名2,...]);
    添加字段默认值(约束):
        alter table 表名 alter [column] 字段名 set default 默认值;
    删除字段默认值(约束):
        alter table 表名 alter [column] 字段名 drop default;
    删除主键:
        alter table 表名 drop primay key;#每一个表最多只能有一个主键
    删除外键:
        alter table 表名 drop foreign key 外键名;
    删除索引:
        alter table 表名 drop index 索引名;
    修改表名:
        alter table 表名 rename [to] 新表名;
    修改表选项:
        alter table 表名 选项名1=选项值1,选项名2=选项值2,...;
    
    
    GROUP_CONCAT()
    
    MYSQL正式读音 My Ess Que Ell  
    
    primary key
    unique key
    foreign key      references 
  • 相关阅读:
    C# 使用消息队列,包括远程访问
    Python3中urllib使用与源代码
    多年前写的DataTable与实体类的转换
    DataTable添加列和行的三种方法
    DevExpress 常用命令包括导出-打印-打印预览等
    c#开发_Dev的关于XtraGrid的使用(GridControl小结)
    正则表达式精华(包涵常用经典方法)
    数据库 插入时 碰到NULL报错判断的一种方法(技巧)
    MDI窗体简单方法(调用,闪屏)
    GridControl GridView 修改表格中的标题居中
  • 原文地址:https://www.cnblogs.com/yangzailu/p/5823757.html
Copyright © 2020-2023  润新知