创建了一个触发器t22_bi,当我们要向表中的行插入时,触发器就会被激活,执行将s1列的值改为55的动作。
CREATE TRIGGER t22_bi
BEFORE INSERT ON t22
FOR EACH ROW
BEGIN
SET @x = ’Trigger was activated!’;
SET NEW.s1 = 55;
END;//
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'orderdate' at row 1
??
(2)创建数据库:
CREATE DATABASE petclinic;
GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc';用户为pc,密码为pc
3。utf8的编码不能存入数据库??
Incorrect string value: '\xE6\x88\x91\xE7\x88\xB1...' for column 'content' at row 1??
利用前端工具修改 每个字段的格式都是gbk,因为你要利用cmd工具来insert数据。
4。SHOW VARIABLES LIKE 'character_set_%';
SHOW VARIABLES LIKE 'collation_%';
1. SET NAMES 'utf8';
它相当于下面的三句指令:
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
2. 创建数据库
mysql> create database name character set utf8;
3. 创建表
CREATE TABLE `type` (
`id` int(10) unsigned NOT NULL auto_increment,
`flag_deleted` enum('Y','N') character set utf8 NOT NULL default 'N',
`flag_type` int(5) NOT NULL default '0',
`type_name` varchar(50) character set utf8 NOT NULL default '',
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
4. 修改数据库成utf8的.
mysql> alter database name character set utf8;
5. 修改表默认用utf8.
mysql> alter table type character set utf8;
6. 修改字段用utf8
mysql> alter table type modify type_name varchar(50) CHARACTER SET utf8;
第二,要把页面的编码修改成UTF-8
如果以上修改后还有乱码的话
因为我没用过apache,我用的是tomcat是要修改server.xml的。