msql 中对库、文件夹、文件的操作

一、库

  库即文件夹 

增:create database db charset utf8;

查:show databases;
      show create database db;

改:alter database db charset gbk;

删:drop database db;

二、文件夹

  在对文件夹进行修改时需要选择对应的库

增:create table student(id int,name char);
    create table db.student(id int,name char);

查:show tables;
    show create table student;
    desc student;

改:alter table student add age int;
    alter table student modify name char(15);
    alter table student change name NAME char(10);

    # 删除表格中的某一个属性
    alter table student drop age;

删:drop table student;    

三、文件

增:insert into student(id,name) values
    (1,'dawang'),
    (2,'xiaoer');

查:select * from student;    
    select name from db.student;
    select id,name from student;
    select id from student where id=2;

改:update db.student set name='DAWANG' where id =1;

删:delete from student where id =1;
       truncate student;
# delete 和 truncate的区别:
# delete 删除表格中某一行时,会保留之前的id,即在之后创建的数据id 都会以之前的为起始
# truncate 清除整个表格,id号会清空,下次新增的id会重新开始计数

猜你喜欢

转载自www.cnblogs.com/Smart1san/p/9339846.html