zoukankan      html  css  js  c++  java
  • CRUD操作

    
    
    MySQL之修改表中的列
    
    修改表中列的语法:
    
    一张表,创建完毕,有了N列。之后还可以增加或删除或修改列
    
    
    增加表中列的语法:
    
    alter table 表名 add 列名称 列类型 列参数; [这样加的列在表的最后]
    例:alter table family add age int
    
     
    
    alter table 表名 add 列名称 列类型 列参数 after 某列; [新列加在某列后]
    例:alter table m1 add username char(20) not null default '';
    
    如果想增加一列,并位于表的最前面,用first
    alter table 表名 add 列名称 列类型 列参数 first;
    例:alter table m1 add pid int not null first;
    
    上面红色字体效果运行后不起作用,可以在表格中拖动列的位置放在目标位置。
    
     
    
    删除表中列的语法:
    
    alter table 表名 drop 列名
    例:alter table family drop age
    
     
    
    修改表中列类型的语法:
    
    alter table 表名 modify 列名 新类型 新参数;
    例:alter table family modify age varchar 
    
     
    
    修改表中列名及类型的语法:
    
    alter table 表名 change 旧列名 新列名 新类型 新参数;
    例:alter table family change name mingzi varchar(20
    
    
    
    CRUD操作
    create 创建
    read 读取
    update 修改
    delete 删除
    
    
    select code ,name from info 读取特定值
    select * from info where code='p003' 条件查询
    select * from info where code='003' or nation='n002' 或的关系 必须有一个满足条件
    select * from info where sex=0 and nation='002' 与的关系 两种都包括
    select * from info where like '_奥迪%'
    select * from info order by code 升序asc 降序 desc
    
    insert into info values('',值) 自增长列的处理
    
    delete from info where code='p002'删除数据
    
    update info set name='梁振',sex=1 where code='p003'
  • 相关阅读:
    「BZOJ 1297」「SCOI 2009」迷路「矩阵乘法」
    「BZOJ 1831」「AHOI 2008」逆序对「贪心」
    「BZOJ 1791」「IOI 2008」Island「基环树」
    WC2019 冬眠记
    「ZOJ 1354」Extended Lights Out「高斯消元」
    「BZOJ 3270」博物馆「高斯消元」
    「学习笔记」泰勒级数
    获取iPhone的UDID
    面试题
    Java的post(HTTPS)请求-----接口测试
  • 原文地址:https://www.cnblogs.com/benpaodegegen/p/5967152.html
Copyright © 2011-2022 走看看