当前位置:网站首页>MySQL - library operation
MySQL - library operation
2022-06-21 10:48:00 【Longbow dog learning C】
Catalog
The impact of different validation rules on the database
Create database
Let's first look at the syntax of database creation :
CREATE DATABASE [IF NOT EXISTS] db_name [create_specification [, create_specification] ...] create_specification: [DEFAULT] CHARACTER SET charset_name [DEFAULT] COLLATE collation_name
- Uppercase means keywords
- [] Optional.
- CHARACTER SET: Specifies the character set used by the database
- COLLATE: Specifies the verification rules for the database character set
Let's take a look at the database created in practice
// Create a db1 The database of
create database db1;This creation does not specify the character set and validation rules to be used , The default character set is :utf8, The verification rule is :utf8_general_ci.
Next, let's create two specific databases ,① Use utf8 Of the character set db2 Database and ② Use utf Character set , With proofreading rules db3 database .
create database db2 charset=utf8;
create database db3 charset=utf8 collate utf8_general_ci;The impact of different validation rules on the database
We can use show collation View the validation rules contained in the database
show collation;

among utf8_ general_ ci and utf8_ bin, The former is not case sensitive , The latter is case sensitive .
// Use validation rules utf8_general_ci( Case insensitive )
create database db1 collate utf8_general_ci;
use db1;
create table tb1(name varchar(20));// Create table tb1
insert into tb1 values('a');
insert into tb1 values('A');
insert into tb1 values('b');
// Use validation rules utf8_bin( Case sensitive )
create database db2 collate utf8_bin;
use db2;
create table tb2(name varchar(20));
insert into tb2 values('a');
insert into tb2 values('A');Let's take a look at the two tables created above ,tb1 and tb2.


Manipulating databases
// view the database show databases;
// Show create statement show create database Database name ;
// Modify the database Syntax ALTER DATABASE db_name [alter_spacification [,alter_spacification]...] alter_spacification: [DEFAULT] CHARACTER SET charset_name [DEFAULT] COLLATE collation_name// take db1 The database character set is changed to gbk alter database db1 charset=gbk;
// Database delete DROP DATABASE [IF EXISTS] db_ name;
边栏推荐
- What USB driver needs to know
- js正则-梳理
- Esp8266/esp32 +1.3 "or 0.96" IIC OLED pointer clock
- 从零开始做网站11-博客开发
- Add solid state to the computer
- Haplotype analysis using shapeit
- DSP online upgrade (4) -- functions implemented by bootloader
- 简易的安卓天气app(三)——城市管理、数据库操作
- Equals and hashcode
- Mythical Games宣布与韩国领先游戏发行商Kakao Games合作,推动亚太区业务扩张
猜你喜欢

应用配置管理,基础原理分析

How to learn function test? Ali engineer teaches 4 steps

Application configuration management, basic principle analysis

Talk about the multimodal project of fire

WPF DataContext 使用

燎原之势 阿里云数据库“百城聚力”助中小企业数智化转型

Simple Android weather app (III) -- city management and database operation

使用shapeit进行单倍型分析

The bilingual live broadcast of Oriental selection is popular, and the transformation of New Oriental is beginning to take shape

Optimisation des performances - compression, chargement et formatage des images
随机推荐
grant all privileges on
给电脑加装固态
记一次协程环境下类成员变量污染的问题
02. Redis Blockbuster: viewing core principles from high-frequency problems
Answers to mobile application development learning general test questions
Stream programming: stream support, creation, intermediate operation and terminal operation
Brief introduction of quality control conditions before genotype filling
Three elements of basic concepts and methods of machine learning
Performance optimization - image compression, loading and format selection
Mythical Games宣布与韩国领先游戏发行商Kakao Games合作,推动亚太区业务扩张
[cloud based co creation] enterprise digitalization accelerates "new intelligent manufacturing"
One of the components of the program
Summary of embedded development -- General Catalog
Cvte side
性能優化——圖片壓縮、加載和格式選擇
Quick sorting, simple and easy to understand principle description, with C code implementation,
Eig and Saudi Aramco signed a memorandum of understanding to expand energy cooperation
Huawei releases wireless innovative products and solutions to build 5gigaverse Society
TensorFlow,危!抛弃者正是谷歌自己
从零开始做网站11-博客开发



