首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >mysql基本总结

mysql基本总结

作者头像
全栈程序员站长
发布2022-07-08 18:54:38
发布2022-07-08 18:54:38
2710
举报

大家好,又见面了,我是全栈君。

创建数据库 creat table test( #整数通常使用int test_id int, #小数通常使用decimal test_price decimal, #普通文本通常使用,并使用Default指定默认值 test_name varchar(255) default “Xxx”, #大文本类型使用test test_desc text, #图片使用blob test_img blob, #日期类型使用DateTime test_date datetime, ); —————————————————————– mysql 支持的列类型 1.tinyint,smallint,mediumint,int,bigint 2.float,double 3.decimal(dec) 4.date 5.time 6.datetime 7.timestamp 8.year 9.char 10.varchar 11.binary(定长的二进制字符串类型。以二进制形式保

存字符串) 12.varbinary 13.tinyblob,blob,mediumblob,longblob 14.tinytext,text,mediumtext,longtext 15.enum(‘value1’,’value2’…)//枚举类型(仅仅能是当中

之中的一个) 16.set(‘value1’,’value2’…)//集合类型(能够是当中几

个) ——————————————————————– #创建数据表,该数据表和user_info全然同样。数据

也全然同样 create table hehe as select * from user_info; ——————————————————————— #改动表的结构的语法 alert table 表名 add( #能够定义多个列定义 colum_name datatype [default expr], … ); ——————————————————————— #为hehe数据表添加一个hehe_id字段,该字段类型为

int

alter table hehe add hehe_id int; #为hehe数据包添加aaa,bbb字段,两个字段的类型都

为varchar(25) alter table hehe add aaa varchar(25),bbb varchar(25); ———————————————————————- #将hehe表的hehe_id列改动为varchar(255)类型 alter table hehe modify hehe_id varchar(255); #将hehe表的bbb列改动为int类型 alter table hehe modify bbb int; ———————————————————————- #删除指定的列 alter table hehe drop column_name #重命名数据表 alter table hehe rename to wawa; ———————————————————————- #将wawa表的字段bbb字段重命名为ddd alter table wawa change bbb ddd int; #删除表 drop table 表名 ———————————————————————- 数据库约束 not null unique primary key foreign key check #not null约束

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116008.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年1月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档