编辑代码

create database mytest;
use mytest;

-- create table t14(
--     birthday date,
--     job_time datetime,
--     login_time timestamp not null default current_timestamp on update current_timestamp
-- );

-- insert into t14(birthday,job_time)
--     values('2001-09-10','2024-08-25 12:34:56');
-- select * from t14;

-- CREATE TABLE emp (

--     id INT,
--     name VARCHAR(32),
--     sex CHAR(1),
--     brithday DATE,
--     entry_date DATETIME,
--     job VARCHAR(32),
--     salary DOUBLE,
--     resume TEXT
-- ) CHARSET utf8 COLLATE utf8_bin ENGINE INNODB;
-- -- 添加一条
-- INSERT INTO emp
--     VALUES(100, '小妖怪', '男', '2000-11-11','2010-11-10 11:11:11', '巡山的', 3000, '大王叫我来巡山');
-- -- SELECT * FROM emp;
-- desc emp;

-- select 语句【重点 难点】
-- CREATE TABLE student(
-- id INT NOT NULL DEFAULT 1,
-- NAME VARCHAR(20) NOT NULL DEFAULT '',
-- chinese FLOAT NOT NULL DEFAULT 0.0,
-- english FLOAT NOT NULL DEFAULT 0.0,
-- math FLOAT NOT NULL DEFAULT 0.0
-- );
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(1,'韩顺平',89,78,90);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(2,'张飞',67,98,56);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(3,'宋江',87,78,77);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(4,'关羽',88,98,90);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(5,'赵云',82,84,67);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(6,'欧阳锋',55,85,45);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(7,'黄蓉',75,65,30);
-- INSERT INTO student(id,NAME,chinese,english,math) VALUES(8,'韩信',45,65,99);

-- select * from student
--     where english between 80 and 90;

-- select * from student
--     where english>=80 and english <= 90;
-- select name,math from student
--     where math in (89,90,91);

-- select * from student
--     where name like '韩%';

-- select * from student
--     where math>80 and chinese>80;

-- select name,(chinese+math+english) as total from student;
--     where (chinese+math+english) in (189,242,276);
-- SELECT SUM(math) FROM student;
-- SELECT CEILING(-1.1) FROM DUAL;
-- SELECT CONV(8, 10, 2) FROM DUAL;
-- SELECT CONV(16, 16, 10) FROM DUAL;

-- SELECT CURRENT_TIMESTAMP() FROM DUAL;

-- select date(current_timestamp) from DUAL;
-- select time(current_timestamp) from DUAL;
-- select date_add(current_time,interval 5 day);

-- select unix_timestamp() from dual;
-- select from_unixtime(1741248595) from dual;
-- select timediff('16:18:19','10:56:18');

-- select datediff('2025-03-06','2001-09-10');

-- select md5('hsp') form dual;