1,create like: use a table to create another same table .ex: CREATE TABLE IF NOT EXISTS tb_test4 LIKE tb_test3; 2,event: CREATE EVENT event_test ON SC ...
1,create like:
use a table to create another same table .
ex: CREATE TABLE IF NOT EXISTS tb_test4 LIKE tb_test3;
2,event:
CREATE EVENT event_test
ON SCHEDULE EVERY 1 SECOND
DO INSERT INTO tb_test_e (username, PASSWORD) VALUES ('w1', 'p1');
SHOW EVENTS;
DROP EVENT event_test;
3,procedure:
DELIMITER //
DROP PROCEDURE IF EXISTS pro_test //
CREATE PROCEDURE pro_test (IN u1 VARCHAR(60), IN p1 VARCHAR(60))
BEGIN
INSERT INTO tb_test_e (username, PASSWORD) VALUES (u1, p1);
END //
DELIMITER ;
CALL pro_test('pu1', 'pp2');
4,check db info:
SHOW DATABASES;
USE db_trad_rm;
SHOW TABLES;
SHOW PROCESSLIST;
SHOW EVENTS;
5, delete
delete from tb_test_e;
truncate tb_test_e;
6, date formate
DELIMITER //
DROP PROCEDURE IF EXISTS proc_test_date //
CREATE PROCEDURE proc_test_date()
BEGIN
DECLARE cur_date_var VARCHAR(20);
SET cur_date_var = DATE_FORMAT(CURDATE(), '%Y%m%d');
SET @date_temp = CONCAT('CREATE TABLE IF NOT EXISTS test_date_', cur_date_var, ' LIKE tb_test3');
SELECT @date_temp;
PREPARE stat_temp FROM @date_temp;
EXECUTE stat_temp;
DEALLOCATE PREPARE stat_temp;
END //
DELIMITER ;
CALL proc_test_date();