mysql基本语法总结
来源:互联网 发布:彩虹六号围攻网络eas 编辑:程序博客网 时间:2024/05/29 16:14
可以放在文件中,然后cmd中输入:source F:\代码。。。。\平时练习代码\数据库\selectDatas.sql
mysql -uroot -puse mysql;--????
创建数据库:
create database javabook;use javabook;
创建表:
create table Course( courseId char(5), subjectId char(4) not null, courseNumber integer, title varchar(50) not null, numOfCredits integer, primary key(courseId));create table Enrollment( ssn char(9), courseId char(5), dateRegistered date, grade char(1), primary key(ssn,courseId), foreign key(ssn) references Student(ssn), foreign key(courseId) references Course(courseId));
删除表:
drop table Course;
插入、更新、删除:
insert into Course (courseId,subjectId,courseNumber,title,numOfCredits)values('1114','CSCJ','3721','Datadase Systemt',4);update Courseset numOfCredits=4where title='Datadase Systems';delete from Coursewhere title='Datadase Systemt';
查询:
select…from…where。
not and or
like(%,_),between…and…,is null
as:别名
distinct:不重复
order by:asc升序,desc降序,默认升序
select numOfCredits,subjectIdfrom Coursewhere courseNumber='3720' and numOfCredits=4;select numOfCredits as "NC",courseNumberfrom Coursewhere numOfCredits between 1 and 10;select title,50*numOfCredits as "minutes per week"from Coursewhere subjectId="CSCI";select distinct subjectId as "Subject ID"from course;select distinct subjectId,titlefrom Course;select lastName,firstName,deptIdfrom Studentwhere deptId='CS'order by lastName desc,firstName asc;
联结表:
select distinct lastName,firstName,courseIdfrom Student,Enrollmentwhere Student.ssn=Enrollment.ssn and lastName='Smith' and firstName='Jacob';--Student.ssn=Enrollment.ssn--
阅读全文
0 0
- mysql基本语法总结
- mysql基本语法总结
- mysql基本语法总结篇
- MySql基本语法参考
- Mysql基本语法
- mysql 基本语法介绍
- Mysql基本语法
- mysql基本语法
- mysql 基本语法
- Mysql基本语法
- MySql基本语法
- mysql基本操作语法
- 讲述MySQL基本语法
- mysql基本语法
- 基本MySQl语法
- mysql基本语法
- mySQL基本语法
- MySQL基本语法命令
- docekr可视化管理软件的使用
- pandas数据结构之Series
- 100种数据恢复的方法?!
- Java+GeoTools工具包+读写shapfile文件
- Css3的Media Query方法总结—让您的网站兼容手机
- mysql基本语法总结
- expdp 导出报ORA-01555: snapshot too old错误
- 浅谈Web网站架构演变过程
- React学习资源汇总
- 根据经纬度算两点距离
- 《算法导论》学习笔记之Chapter8线性时间排序
- firewalld火墙设置
- API开发之封装接口数据返回函数
- OpenJ_Bailian 4127 迷宫问题(DFS+BFS)