mysql中有哪些增、删、改、查语句

发布时间:2021-05-11 18:31:59 作者:Leah
来源:亿速云 阅读:153

mysql中有哪些增、删、改、查语句?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

1、创建db_shop数据库,如果该数据库不存在则创建

create database if not exists db_shop;

2、删除数据库,如果该数据存在就删除

drop database if exists db_shop;

3、给db_shop创建数据表

use db_shop;
drop table if exists tb_goods;
CREATE TABLE tb_goods(
 `goodsId` int(11) NOT NULL AUTO_INCREMENT,
 PRIMARY KEY (`tb_goods`)
);

4、根据旧表创建新表

create table tb_goods01 like tb_goods;

5、删除数据表

drop table tb_goods01;

6、给一个表增加一列(一个字段)

alter tb_goods add column goodsName varchar(255) after goodsId;

注意:不写after、before则默认添加到最后

7、删除字段

alter table tb_goods drop column goodsName;

8、插入数据

insert into tb_goods (goodsId,goodsName) values (1002,'商品1');

9、查询

查询所有

select * from tb_goods;

查询特定

select goodsName fromtb_goods;

模糊查找

select * from tb_goods like '%商品%';

10、更新数据表

update tb_goods set goodsName='商品2';

关于mysql中有哪些增、删、改、查语句问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。

推荐阅读:
  1. redis cluster 集群搭建(增、删、改、查) :5.0.2
  2. SQLServer之T-SQL增、删、改、查

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql

上一篇:使用jQuery怎么实现数字自动增加或减少

下一篇:如何在Python中使用类的继承

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》