Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構

6.11. MySQL 專有命令

6.11.1. SQL_NO_CACHE

SELECT /*!40001 SQL_NO_CACHE */ * FROM table
		

6.11.2. SIGNAL Syntax

DROP TRIGGER `members_before_insert`;
CREATE DEFINER=`neo`@`%` TRIGGER `members_before_insert` BEFORE INSERT ON `members` FOR EACH ROW BEGIN
	IF new.username IS NOT NULL THEN
		IF not exists(select username from members_available where username = new.username) THEN
	   	/*set new.username = NULL;*/
	   	SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'An error occurred', MYSQL_ERRNO = 1001;
		END IF;
	END IF;
END;