www.9778.comMySQL chartset

-- # https://dev.mysql.com/doc/refman/8.0/en/charset-database.html-- create database aixinyz; -- 默認為:latin1,以安裝MYSQL時,默認,當害安裝時選了UTF-8就好了,沒有隻能代碼實現-- 創建數据的編碼格式-- CREATE DATABASE aixinyz CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;-- CREATE DATABASE aixinyz CHARACTER SET utf8 COLLATE utf8_general_ci;-- 查詢編碼格式show variables like '%char%';-- SET NAMES GB2312; ALTER DATABASE db_aixinyz_comDEFAULT CHARACTER SET utf8DEFAULT COLLATE utf8_general_ci;-- 修改數据的編碼格式ALTER DATABASE aixinyz DEFAULT CHARACTER SET utf8 -- default character set=utf8 -- default character set server=utf8 -- default collation server=utf8_general_ci DEFAULT COLLATE utf8_general_ci;  -- 設置 SET character_set_server = utf8;set character_set_results=gb2312; select 'host' from user; -- where user='root'; /* character_set_client   utf8character_set_connection    utf8character_set_database  latin1 -- phpmyadmin2 客戶查詢亂碼character_set_filesystem  binarycharacter_set_results utf8character_set_server    latin1character_set_system  utf8mysql> SET character_set_client = utf8 ;mysql> SET character_set_connection = utf8 ;mysql> SET character_set_database = utf8 ;mysql> SET character_set_results = utf8 ;mysql> SET character_set_server = utf8 ; mysql> SET collation_connection = utf8 ;mysql> SET collation_database = utf8 ;mysql> SET collation_server = utf8 ; */ SHOW DATABASES; SHOW DATABASES; -- 列出 MySQL Server 上的資料庫。SHOW TABLES FROM test; -- 列出資料庫的資料表。SHOW TABLE STATUS FROM test; -- 列出資料庫的資料表,提供比較詳細的訊息。SHOW COLUMNS FROM test; -- 列出資料表的欄位,同 SHOW FIELDS FROM tbl_name [FROM db_name],DESCRIBE tbl_name [col_name]。SHOW FULL COLUMNS FROM test; -- 列出資料表的欄位,提供比較詳細的訊息,同 SHOW FULL FIELDS FROM tbl_name [FROM db_name]。SHOW INDEX FROM test; -- 列出資料表的索引訊息。SHOW STATUS; -- 列出 Server 的狀態訊息。SHOW VARIABLES; -- 列出 MySQL 系統變數的值。SHOW PROCESSLIST; -- 顯示哪個執行緒正在運行。SHOW GRANTS FOR user; -- 列出對一個用戶必須發出以重複授權的授權命令---- 表的结构 `test`--DROP TABLE `test`;DROP TABLE IF EXISTS `test`;CREATE TABLE IF NOT EXISTS `test` ( `id` int(11) NOT NULL comment 'ID号' auto_increment, `names` varchar(255) character set utf8 NOT NULL default 'geovindu' COMMENT '姓名', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='geovindu 塗聚文測試表' AUTO_INCREMENT=2 ;---- 转存表中的数据 `test`--select * from test;-- 修改表的注释alter table test comment '修改后的塗聚文測試表';-- 修改字段的注释alter table test modify column `id` int comment 'ID号';alter table test modify column `names` varchar(255) COMMENT '姓名';-- 在生成的SQL语句中看show create table test;-- 在元数据的表里面看use information_schema;select * from TABLES where TABLE_SCHEMA='aixinyz' and TABLE_NAME='test';-- 查看字段注释的方法-- V 5.7show full columns from `test`;-- 在元数据的表里面看select * from COLUMNS where TABLE_SCHEMA='aixinyz' and TABLE_NAME='test';-- 删除一个字段alter table test DROP COLUMN new2;-- -- 修改一个字段的类型alter table test MODIFY new1 VARCHAR(10);-- 修改一个字段的名称,此时一定要重新指定该字段的类型alter table test CHANGE new1 new4 int;-- 增加一个字段,默认为空alter table test add geovindu VARCHAR(20) DEFAULT NULL;alter table test add geovindu VARCHAR(20) DEFAULT NULL COMMENT '塗聚文' AFTER `names`;-- 增加一个字段,默认不能为空alter table test add `address` VARCHAR(20) NOT NULL COMMENT '塗聚文' AFTER `names`;alter table test add `address` VARCHAR(20) NOT NULL after `names`;

www.9778.comMySQL chartset。