时间:2021-07-01 10:21:17 帮助过:14人阅读
modify
change
add
dorp
向表里添加一行course
mysql> alter table students add course varchar(100);
修改course为coures,并且修改其类型为varchar(100),并放到name后面:
mysql> alter table students change course coures varchar(100) after name;
DML:
insert into tb_name (col1,col2,...) values|value (‘steing‘,num,...)
#replace into 直接替换
向students表里同时插入2个字段的内容
mysql> insert into students (Name,gender) value (‘zhangsan‘,‘M‘),(‘wangwu‘,‘F‘);
select * from students;
插入单条数据
mysql> insert into students values (‘zhaoliu‘,‘yuwen‘,12,‘M‘);
修改数据:
update TB_NAME SET column=value WHERE
mysql> update students set coures=‘shuxue‘ where name=‘wangwu‘;
只显示指定字段:
mysql> select Name,Age from students;
查找students表里,gender为M的字段。并且只显示其Name和coures:
mysql> select Name,coures from students where gender=‘M‘;
删除:
delete from tb_name where
删除coures=yuwen的字段
mysql> delete from students where coures=‘yuwen‘;
选择:select 字段 from TB_NAME WHERE CONDITION
*表示所有字段
where 没有条件显示所有行
创建用户:
create user ‘USERNAME‘@‘HOST‘ identified by ‘password‘;
drop user ‘USERNAME‘@‘HOSR‘;
HOST:
IP;
HOSTNAME;
NERWORK;
通配符;
_:匹配任意单个字符,172.16.0._ 从0.1-0.9
%:匹配任意长度任意字符
derry@‘%‘ 表示这个账户可以在人任何主机上登陆
DCL:
创建jerry用户指定为所有主机都可以登陆密码为jerry:
mysql> create user ‘jerry‘@‘%‘ identified by ‘jerry‘;
查看此用户的权限:
mysql> show grants for ‘jerry‘@‘%‘;
让次用户拥有所有权限
all pricileges
mysql> grant all privileges on mysql.* to ‘jerry‘@‘%‘;
本文出自 “运维成长路” 博客,谢绝转载!
MySQL语句
标签:mysql语句