mysql操作表结构的语法

  • 创建表

    create table test_page_list
    (eid int primary key,
    ename varchar(45)) charset=utf8;
    
  • 修改表结构

    alter table test_page_list character set utf8;
    
  • 删除表

    DELETE FROM test_page_list WHERE id ='3';
    
  • 增加表字段

    ALTER TABLE mysql.test_page_list ADD url VARCHAR(64) NOT NULL;
    
  • 删除表字段

    ALTER TABLE mysql.test_page_list DROP name;
    

mysql操作表中数据的语法

  • 查询语句:全部查询、联合查询、模糊查询:

    SELECT * FROM test_page_list ;
    SELECT * FROM test_page_list WHERE businesstype = '研招' AND runtype ='后台推送';/*多个查询添加查询*/
    SELECT * FROM test_page_list WHERE name LIKE '%%' AND runtype ='';/*模糊查询*/
    
  • 新增语句

    insert into test_page_list SET id='1509348274956',name='张三',url='/index.html',businesstype='',datatime='2017-10-30 15:13:36' ;
    
  • 更新语句

    UPDATE test_page_list SET name='总共-' ,url='12' ;
    UPDATE test_page_list SET name='12',url='中文',businesstype='对外推广,高考' where id=1;//条件语句
    
  • 删除语句

    DELETE FROM test_page_list WHERE id ='3';
    

以上文章来自:黄卉 , https://huanghui8030.github.io/mysql/yf.html