/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

CREATE DATABASE IF NOT EXISTS `test_views` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
USE `test_views`;

CREATE TABLE IF NOT EXISTS `test` (
  `PrimKey` int(11) NOT NULL AUTO_INCREMENT,
  `Account` int(11) NOT NULL,
  `SomeValue` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`PrimKey`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*!40000 ALTER TABLE `test` DISABLE KEYS */;
INSERT INTO `test` (`PrimKey`, `Account`, `SomeValue`) VALUES
	(1, 1, 'AAA'),
	(2, 1, 'BBB'),
	(3, 2, 'CCC'),
	(4, 2, 'DDD');
/*!40000 ALTER TABLE `test` ENABLE KEYS */;

CREATE TABLE `view_test` (
	`PrimKey` INT(11) NOT NULL,
	`Account` INT(11) NOT NULL,
	`SomeValue` VARCHAR(100) NOT NULL COLLATE 'utf8mb4_unicode_ci'
) ENGINE=MyISAM;

DROP TABLE IF EXISTS `view_test`;
CREATE ALGORITHM=MERGE DEFINER=`root`@`127.0.0.1` SQL SECURITY DEFINER VIEW `view_test` AS SELECT *
FROM test
WHERE test.Account = 1 WITH CASCADED CHECK OPTION ;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
