mysql十分全的和完整的总结
mysql非常全的和完整的总结 (1)数据类型 类型 备注 tinyint/smallint/mediumint/int/bigint 1B/2B/3B/4B/8B float/double 单精度/双精度浮点型 decimal 不会产生精度丢失的单精度/双精度浮点型 date 日期类型 time 时间类型 datetime/ TimeStamp 日期时间类型
mysql非常全的和完整的总结(1)数据类型
类型 |
备注 |
tinyint/smallint/mediumint/int/bigint |
1B/2B/3B/4B/8B |
float/double |
单精度/双精度浮点型 |
decimal |
不会产生精度丢失的单精度/双精度浮点型 |
date |
日期类型 |
time |
时间类型 |
datetime/TimeStamp |
日期时间类型/TimeStamp(登录时间,自动填充) |
year |
年类型 |
char |
定长字符串类型 |
varchar |
可变长字符串类型 |
tinyblob/blob/mediumblob/longblob |
255B/64K/16M/4G大小图片/音乐二进行数据 |
tinytext/text/mediumtext/longtext |
255B/64K/16M/4G大小的文本数据 |
(2)mysql小知识
①登录
mysql > mysql -u root -p回车
****回车
mysql > exit回车
②创建/使用/查看/删除数据库
create database 数据库名;(以分号结束),SQL命令大小写无关
show databases;
use 数据库名;
③修改/备份/恢复数据库数据
备份:c:\> mysqldump -u root -p mydb2 > d:\mydb2.sql回车(可无分号结束)密码回车
注意:该SQL命令是MySQL特有的,必须是MySQL环境外执行,即WindowXp环境中执行(退出mysql平台)
恢复:mysql:\> source d:\mydb2.sql;回车(需要分号结束)
注意:该SQL命令是MySQL特有的,必须是MySQL环境中执行。
④MySQL支持数据类型简介
(1)Date/Datetime/TimeStamp,定界符使用''或"",但部份数据库可能不支持"",优先推荐''作为定界符,对于日期类型,MySQL数据库有一个的判段-功能
(2)varchar(变长)/char(定长)
(3)Text(大于65536字符的数据)/Blob(存储二进制多媒体数据,例如Mp3等),该二类型都有四个子类型,根据存储内容的大小进行选择
(4)INT型有带符号和无符号之分,int(5)表示int默认为5位,如果插入id值,小于5位,左补空格,如果插入id值,大于5位,按照插入值,但必须满足int类型的大小确定
(5)FLOAT(M,D),D表示小数点后的D位,按四舍五入计算,M表示除小数点外的所有位数总和
⑤MySQL修改表和字符集
show variables like 'character%';
set character_set_results=gbk;
(3)MySQL解决中文乱码(XP下)
2种解决方法:
a)在当前MySQL客户端修改输入和输出的MySQL环境变量为GBK或GB2312,注意,该种方式只在当前窗口中有效
b)修改MySQL目录下的my.ini文件,将客户端的缺省编码方式改为GBK或GB2312,注意,需要重新启动MySQL服务
(4)表的增删改操作
a)insert
b)update
c)delete from 或truncate table或drop table
delete from:按行删除表中的所有记录,但会保留表,适合删除数据量不大数据,可按条件删除
truncate table:复制原表结构-〉一次性删除整表 -> 自动恢复原表结构,适合删除数据量较大数据,不能按条件删除
drop table:删除表本身
删除记录时,一定要留意表间的关联关系
(5)表的查询操作
(1)select distinct/*/列名 from 表名
(2)select 表达式/对列名加别名 from 表名 NULL+X=NULL
(3)where子句,出现在from后面,where是按行筛选
(4)逻辑运算和关系运算
(5)排序:NULL值为最小,使用order by子句,默认升序,order by子句必须放置在最后
(6)复合函数
①count()函数,统计之用,不统计NULL值
②sum()函数,统计和之用,不要统计非数值,如果统计非数值,返回0

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.
