
MYSQL
文章平均质量分 66
dancheren
这个作者很懒,什么都没留下…
展开
-
MySQL-Rank Scores
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value.原创 2017-03-05 14:14:50 · 672 阅读 · 0 评论 -
索引基础——B-Tree、B+Tree、红黑树、B*Tree数据结构
B树(B-Tree,并不是B“减”树,横杠为连接符,容易被误导) 是一种多路搜索树(并不是二叉的): 1.定义任意非叶子结点最多只有M个儿子;且M>2; 2.根结点的儿子数为[2, M]; 3.除根结点以外的非叶子结点的儿子数为[M/2, M]; 4.每个结点存放至少M/2-1(取上整)和至多M-1转载 2017-06-20 20:26:15 · 460 阅读 · 0 评论 -
MySQL事务处理
START TRANSACTION,COMMIT和ROLLBACK语法START TRANSACTION | BEGIN [WORK]COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]SET AUTOCOMMIT = {0 | 1}以下语句提供事原创 2017-06-06 22:17:51 · 531 阅读 · 0 评论 -
MySQL查询练习题
成绩管理系统的数据操作介绍在挑战实验1中构建的成绩管理系统中,物理老师想要找出分数最高的同学进行表扬,请你找出这个同学并把他的信息(id、姓名、性别)输出到路径 /tmp/ 下的 physics.txt文件中。同时 Tom 的化学成绩有异议,需要在原来的基础上加3分,请更新 Tom 的化学成绩。创建成绩管理系统数据库的代码在 createdb.sql 中,请打开原创 2017-06-05 21:14:25 · 1912 阅读 · 0 评论 -
MySQL-获取当天时间、前几天时间函数
取得当天:SELECT curdate();mysql> SELECT curdate();+------------+| curdate() |+------------+| 2013-07-29 |+------------+ 取得当前日期:mysql> select now();+---------------------+原创 2017-04-13 22:06:38 · 5621 阅读 · 1 评论 -
MySQL-Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exa原创 2017-03-03 19:40:31 · 824 阅读 · 0 评论 -
MySQL-Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.+----+------------------+| Id | Email |+----+-----原创 2017-03-09 14:59:31 · 395 阅读 · 0 评论 -
mysql导入数据到空表
创建一张空表,比如:create table test( name varchar(25), age int(4));test表的数据从外部导入的sql语句:load data local infile 'e:\data.txt' into table test lines terminated by '\r\n';说明:外部文件数据格式必须与表中结构对应,每一行原创 2017-02-14 16:26:45 · 1819 阅读 · 0 评论 -
MySQL-索引、视图、导入、导出、备份、恢复
1、索引索引是一种与表有关的结构,它的作用相当于书的目录,可以根据目录中的页码快速找到所需的内容。当表中有大量记录时,若要对表进行查询,没有索引的情况是全表搜索:将所有记录一一取出,和查询条件进行一一对比,然后返回满足条件的记录。这样做会消耗大量数据库系统时间,并造成大量磁盘 I/O 操作。而如果在表中已建立索引,在索引中找到符合查询条件的索引值,通过索引值就可以快速找到表原创 2017-02-14 08:59:03 · 7218 阅读 · 0 评论 -
MySQL-删除与修改
1、对数据库的修改使用命令 SHOW DATABASES; 可以看到刚才运行MySQL-05.sql 文件生成的两个数据库:现在我们运行命令删除名为 test_01 的数据库:DROP DATABASE test_01;现在再次使用命令 SHOW DATABASES; 可以发现,test_01 数据库已经被成功删除:2、对一张表的修改(原创 2017-02-14 08:56:56 · 572 阅读 · 0 评论 -
MySQL-SELECT 语句详解
在数据库操作语句中,使用最频繁,也被认为最重要的是 SELECT 查询语句。之前的实验中,我们已经在不少地方用到了 SELECT * FROM table_name; 这条语句用于查看一张表中的所有内容。 而 SELECT 与各种限制条件关键词搭配使用,具有各种丰富的功能,这次实验就进行详细介绍。1、基本的SELECT语句SELECT 语句的基本格式为:SELECT 要查询原创 2017-02-14 08:41:12 · 43587 阅读 · 3 评论 -
MySQL-约束
1、约束分类听名字就知道,约束是一种限制,它通过对表的行或列的数据做出限制,来确保表的数据的完整性、唯一性。在MySQL中,通常有这几种约束:约束类型:主键默认值唯一外键非空关键字:PRIMARY KEYDEFAULTUNIQUEFOREIGN KEYNOT NULL原创 2017-02-14 08:38:41 · 386 阅读 · 0 评论 -
MySQL-Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.+----+-------+--------+--------------+| Id | Name | Salary | Departme原创 2017-03-07 19:15:53 · 445 阅读 · 0 评论 -
MySQL-Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For原创 2017-03-06 19:21:01 · 307 阅读 · 0 评论 -
MySQL-Employees Earning More Than Their Managers
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary |原创 2017-03-06 19:11:12 · 262 阅读 · 0 评论 -
MySQL-Consecutive Numbers
Write a SQL query to find all numbers that appear at least three times consecutively.+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 1 || 6 | 2原创 2017-03-06 18:56:36 · 593 阅读 · 0 评论 -
MySQL-Rising Temperature
Given a Weather table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.+---------+------------+------------------+| Id(INT) | Date(DA原创 2017-03-09 15:25:05 · 253 阅读 · 0 评论 -
MySQL-Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For exampl原创 2017-03-05 13:13:48 · 400 阅读 · 0 评论 -
阿里云ECS服务器中自带MYSQL无法登陆问题
阿里云服务器自带mysql数据库,我们可以通过 yum list installed | grep mysql 命令来查看系统装好的mysql。[dancheren@iZ2ze3n5edj5u2cbb9qrijZ /]$ yum list installed | grep mysqlmysql-community-client.x86_64 5.7.16-1.el7原创 2017-07-22 21:05:26 · 2276 阅读 · 0 评论