代码改变世界

java mysql的应用知识

2018-05-03 19:58  yelena  阅读(181)  评论(0编辑  收藏  举报
 
 CREATE TABLE yuangong(
             id INT,
             NAME VARCHAR(20),
             gender VARCHAR(2),
             birthday DATE,
             email VARCHAR(10),
             remark VARCHAR(50)
             );
  /*查询表结构*/
  DESC yuangong;
  /*增加一列*/
  ALTER TABLE yuangong ADD COLUMN age INT;
  /*改变属性值*/
  ALTER TABLE yuangong MODIFY COLUMN email VARCHAR(50);
  /*删除一列*/
  ALTER TABLE yuangong DROP COLUMN remark;
  /*改变列名称*/
  ALTER TABLE yuangong CHANGE COLUMN NAME username VARCHAR(20);
  /*增加数据*/
  INSERT INTO yuangong VALUES(1,'张三','','2000-02-02','123@qq.com',18);
  INSERT INTO yuangong VALUES(3,'张三','','2000-02-02','123@qq.com',18);
  SELECT *FROM yuangong;
  /*增加部分数据*/
  INSERT INTO yuangong(id,username) VALUES(2,'李四');
  /*改变数据(有条件的)*/
  UPDATE yuangong SET username='王五' WHERE id=3;
  /*删除数据*/
  DELETE FROM yuangong WHERE id=2;
  DELETE FROM yuangong WHERE id=1;
  DELETE FROM yuangong WHERE id=3;