#创建数据库
CREATE DATABASE IF NOT EXISTS info DEFAULT CHARSET utf8;
USE info;
#创建表
CREATE TABLE IF NOT EXISTS emp(emp_id INT PRIMARY KEY AUTO_INCREMENT,
emp_name VARCHAR(20),
salary INT,
dept_id INT,
manager_id INT
);
SELECT * FROM emp WHERE emp_name = "父";
#1.1.创建索引:单独创建索引
CREATE INDEX index_name ON emp(emp_name);
SELECT * FROM emp WHERE emp_name = "父";
#1.2.创建索引:修改表结构创建索引
ALTER TABLE emp ADD INDEX index_salary(salary);
#1.3.创建索引:创建表时,创建索引
CREATE TABLE IF NOT EXISTS article(id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(30) UNIQUE,
content VARCHAR(50),
dt DATE,
PRIMARY KEY(id),
INDEX index_title (title)
);
#2.删除索引
DROP INDEX index_name ON emp;
#3.1.单独创建唯一索引:列的值必须唯一
CREATE UNIQUE INDEX index_name ON emp(emp_name);
#4.1.单独创建组合索引
CREATE INDEX index_ct ON article(content,dt);
SELECT