色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

mysql數據庫的對象有

方一強2年前10瀏覽0評論

MySQL數據庫的對象有:數據庫、表、視圖、存儲過程、函數、觸發器、事件等。

創建數據庫:
CREATE DATABASE `mydb`;
創建表:
CREATE TABLE `mytable` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`age` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
創建視圖:
CREATE VIEW `myview` AS
SELECT `name`, `age` FROM `mytable` WHERE `age` >18;
創建存儲過程:
CREATE PROCEDURE `myproc` (IN `myname` VARCHAR(50), OUT `myage` INT)
BEGIN
SELECT `age` INTO `myage` FROM `mytable` WHERE `name` = `myname`;
END;
創建函數:
CREATE FUNCTION `myfunc` (`name` VARCHAR(50)) RETURNS INT
BEGIN
DECLARE `myage` INT;
SELECT `age` INTO `myage` FROM `mytable` WHERE `name` = `name`;
RETURN `myage`;
END;
創建觸發器:
CREATE TRIGGER `mytrigger` BEFORE INSERT ON `mytable`
FOR EACH ROW
BEGIN
SET NEW.`name` = UPPER(NEW.`name`);
END;
創建事件:
CREATE EVENT `myevent`
ON SCHEDULE EVERY 1 DAY
DO
DELETE FROM `mytable` WHERE `age`< 18;