mysql database basic statement training question detailed code
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- Table structure for course -- ---------------------------- DROP TABLE IF EXISTS `course`; CREATE TABLE `course` ( `cno` varchar(10) DEFAULT NULL, `Cname` varchar(255) DEFAULT NULL, `tno` varchar(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of course -- ---------------------------- INSERT INTO `course` VALUES ('01', '语文', '02'); INSERT INTO `course` VALUES ('02', '数学', '01'); INSERT INTO `course` VALUES ('03', '英语', '03'); -- ---------------------------- -- Table structure for sc -- ---------------------------- DROP TABLE IF EXISTS `sc`; CREATE TABLE `sc` ( `sno` varchar(10) DEFAULT NULL, `cno` varchar(10) DEFAULT NULL, `score` decimal(18,1) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of sc -- ---------------------------- INSERT INTO `sc` VALUES ('01', '01', '80.0'); INSERT INTO `sc` VALUES ('01', '02', '90.0'); INSERT INTO `sc` VALUES ('01', '03', '99.0'); INSERT INTO `sc` VALUES ('02', '02', '60.0'); INSERT INTO `sc` VALUES ('02', '03', '80.0'); INSERT INTO `sc` VALUES ('03', '01', '80.0'); INSERT INTO `sc` VALUES ('03', '02', '80.0'); INSERT INTO `sc` VALUES ('03', '03', '80.0'); INSERT INTO `sc` VALUES ('04', '01', '50.0'); INSERT INTO `sc` VALUES ('04', '02', '30.0'); INSERT INTO `sc` VALUES ('04', '03', '20.0'); INSERT INTO `sc` VALUES ('05', '01', '76.0'); INSERT INTO `sc` VALUES ('05', '02', '87.0'); INSERT INTO `sc` VALUES ('06', '01', '31.0'); INSERT INTO `sc` VALUES ('06', '03', '34.0'); INSERT INTO `sc` VALUES ('07', '02', '89.0'); INSERT INTO `sc` VALUES ('07', '03', '98.0'); -- ---------------------------- -- Table structure for student -- ---------------------------- DROP TABLE IF EXISTS `student`; CREATE TABLE `student` ( `sno` varchar(10) DEFAULT NULL, `Sname` varchar(255) DEFAULT NULL, `Sage` datetime DEFAULT NULL, `Ssex` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of student -- ---------------------------- INSERT INTO `student` VALUES ('01', '赵雷', '1990-01-01 00:00:00', '男'); INSERT INTO `student` VALUES ('02', '钱电', '1990-12-21 00:00:00', '男'); INSERT INTO `student` VALUES ('03', '孙风', '1990-05-20 00:00:00', '男'); INSERT INTO `student` VALUES ('04', '李云', '1990-08-06 00:00:00', '男'); INSERT INTO `student` VALUES ('05', '周梅', '1991-12-01 00:00:00', '女'); INSERT INTO `student` VALUES ('06', '吴兰', '1992-03-01 00:00:00', '女'); INSERT INTO `student` VALUES ('07', '郑竹', '1989-07-01 00:00:00', '女'); INSERT INTO `student` VALUES ('08', '王菊', '1990-01-20 00:00:00', '女'); -- ---------------------------- -- Table structure for teacher -- ---------------------------- DROP TABLE IF EXISTS `teacher`; CREATE TABLE `teacher` ( `tno` varchar(10) DEFAULT NULL, `Tname` varchar(255) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of teacher -- ---------------------------- INSERT INTO `teacher` VALUES ('01', '张三'); INSERT INTO `teacher` VALUES ('02', '李四'); INSERT INTO `teacher` VALUES ('03', '王五'); -- ---------------------------- -- Table structure for users -- ---------------------------- DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(10) NOT NULL AUTO_INCREMENT, `username` varchar(20) DEFAULT NULL, `password` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; -- ---------------------------- -- Records of users -- ---------------------------- INSERT INTO `users` VALUES ('1', 'aaa', 'ab\'c');
Student(Sno,Sname,Sage,Ssex) 学生表 Course(Cno,Cname,Tno) 课程表 SC(Sno,Cno,score) 成绩表 Teacher(Tno,Tname) 教师表 问题: 1、查询“001”课程比“002”课程成绩高的所有学生的学号; 2、查询平均成绩大于60分的同学的学号和平均成绩; 3、查询所有同学的学号、姓名、选课数、总成绩; 4、查询姓“李”的老师的个数; 5、查询没学过“叶平”老师课的同学的学号、姓名; 6、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名; 7、查询学过“叶平”老师所教的所有课的同学的学号、姓名; 8、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名; 9、查询所有课程成绩小于60分的同学的学号、姓名; 10、查询没有学全所有课的同学的学号、姓名; 11、查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名; 12、查询至少学过学号为“001”同学所有一门课的其他同学学号和姓名; 13、把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩; 14、查询和“1002”号的同学学习的课程完全相同的其他同学学号和姓名; 15、删除学习“叶平”老师课的SC表记录; 16、向SC表中插入一些记录,这些记录要求符合以下条件:没有上过编号“003”课程的同学学号、2、 号课的平均成绩; 17、按平均成绩从高到低显示所有学生的“数据库”、“企业管理”、“英语”三门的课程成绩,按如下形式显示: 学生ID,,数据库,企业管理,英语,有效课程数,有效平均分 18、查询各科成绩最高和最低的分:以如下形式显示:课程ID,最高分,最低分 19、按各科平均成绩从低到高和及格率的百分数从高到低顺序 20、查询如下课程平均成绩和及格率的百分数(用"1行"显示): 企业管理(001),马克思(002),OO&UML (003),数据库(004) 21、查询不同老师所教不同课程平均分从高到低显示 22、查询如下课程成绩第 3 名到第 6 名的学生成绩单:企业管理(001),马克思(002),UML (003),数据库(004) 23、统计列印各科成绩,各分数段人数:课程ID,课程名称,[100-85],[85-70],[70-60],[ <60] 24、查询学生平均成绩及其名次 25、查询各科成绩前三名的记录:(不考虑成绩并列情况) 26、查询每门课程被选修的学生数 28、查询男生、女生人数 29、查询姓“张”的学生名单 30、查询同名同性学生名单,并统计同名人数 31、1981年出生的学生名单(注:Student表中Sage列的类型是datetime) 32、查询每门课程的平均成绩,结果按平均成绩升序排列,平均成绩相同时,按课程号降序排列 33、查询平均成绩大于85的所有学生的学号、姓名和平均成绩 34、查询课程名称为“数据库”,且分数低于60的学生姓名和分数 35、查询所有学生的选课情况; 36、查询任何一门课程成绩在70分以上的姓名、课程名称和分数; 37、查询不及格的课程,并按课程号从大到小排列 38、查询课程编号为003且课程成绩在80分以上的学生的学号和姓名; 39、求选了课程的学生人数 40、查询选修“叶平”老师所授课程的学生中,成绩最高的学生姓名及其成绩 41、查询各个课程及相应的选修人数 42、查询不同课程成绩相同的学生的学号、课程号、学生成绩 43、查询每门功成绩最好的前两名 44、统计每门课程的学生选修人数(超过10人的课程才统计)。要求输出课程号和选修人数,查询结果按人数降序排列,查询结果按人数降序排列,若人数相同,按课程号升序排列 45、检索至少选修两门课程的学生学号 46、查询全部学生都选修的课程的课程号和课程名 47、查询没学过“叶平”老师讲授的任一门课程的学生姓名 48、查询两门以上不及格课程的同学的学号及其平均成绩 49、检索“004”课程分数小于60,按分数降序排列的同学学号 50、删除“002”同学的“001”课程的成绩
The above is the content of the mysql database basic statement training question detailed code. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool