- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
MySql数据库的一些用法
drop database if exists select_test;
create database select_test;
#进入指定数据库
use select_test;
#查看空表结构
desc 表名;
# 为了保证从表参照的主表存在,通常应该先建主表。
create table teacher_table
(
# auto_increment:实际上代表所有数据库的自动编号策略,通常用作数据表的逻辑主键。
teacher_id int auto_increment,
teacher_name varchar(255),
primary key(teacher_id)
);
create table student_table
(
# 为本表建立主键约束
student_id int auto_increment primary key,
student_name varchar(255),
# 指定java_teacher参照到teacher_table的teacher_id列
java_teacher int,
foreign key(java_teacher) references teacher_table(teacher_id)
);
create table img_table
(
img_id int auto_increment primary key,
img_name varcher(50),
#创建一个mediumblob类型的数据列,用于保存图片等数据
img_data mediumblob
);
//插入数据
insert into teacher_table values(null , Yeeku);
insert into teacher_table values(null , Leegang);
insert into teacher_table values(null , Martine);
insert into student_table values(null , 张三 , 1);
insert into student_table values(null , 张三 , 1);
insert into student_table values(null , 李四 , 1);
insert into student_table values(null , 王五 , 2);
insert into student_table values(null , _王五 , 2);
insert into student_table values(null , null , 2);
insert into student_table values(null , 赵六 , null);
insert into student_table(student_name) values(‘王六’);
//修改数据
update student_table set student_name=孙悟空 where student_id=3;
//如果二张表有一个字段的值是一样的话,可以根据一张表当他们的字段值相等而修改另一张表的其它数据
update user, postmessage set headImage=fdfsd where userName = P_userName;
//删除数据
delete from student_table2 where student_id2;
//重命名数据库
alter table 表名 rename to 新表名;
//修改列名
alter table 表名 modify 列名 列名类型;
//从数据表中删除列
alter table 表名 drop 列名;
//删除表
drop table 表名;
//not null 约束
java_teacher int not null;
//unique 唯一约束
student_name varchar(50) unique;
//check 约束, check(逻辑表达式)
check(age18 and age25);
//创建索引
create index 索引名 on 表名(列名);
//创建视图,并使用as 子查询
create view 视图名
as
select teacher_name from teacher_table
#指定不允许修改视图的数据
with check option;
//查询语句
select student_name from student_table where java_te
您可能关注的文档
- C语言需要记忆点.ppt
- 生物记忆知识点.ppt
- 三极管MOS管开关.ppt
- VerilogHDL_2.ppt
- 第二章 会计电算化的工作环境 第一节 计算机一般知识.doc
- Unit7 听说quiz.doc
- 集成触发器(易理解).ppt
- 计算机未来发展展型.doc
- 晶体三极管和场效晶体管02.ppt
- 第 1 章.3三极管.ppt
- 2025年氯系漂白助剂项目规划申请报告.docx
- 2025年vb程序设计试题及答案.doc
- 2025年党史知识竞赛试题及答案.doc
- 2025年秘密花园测试题及答案.doc
- 解析卷-苏科版九年级物理上册《机械能和内能》综合测评试卷(含答案详解版).docx
- 难点解析-苏科版九年级物理上册《机械能和内能》难点解析试题(含解析).docx
- 考点解析-苏科版九年级物理上册《机械能和内能》综合练习练习题(含答案详解).docx
- 考点解析苏科版九年级物理上册《机械能和内能》专题测评试卷(含答案详解版).docx
- 苏科版九年级物理上册《机械能和内能》定向攻克试题(含详解).docx
- 2025年河北省邢台市行政职业能力测验模拟试题及参考答案.docx
文档评论(0)