MySQL学习笔记_2_SQL数据模型和数据类型_MySQL
bitsCN.com
MySQL创建数据表(上)
一、创建数据表的SQL语句模型【弱类型】
CREATE TABLE [IF NOT EXISTS] 表名称(
字段名1 列的类型 [属性][索引],
字段名2 列的类型 [属性][索引],
…
字段名n 列的类型 [属性][索引],
)[表属性][表字符集];
【表名称,字段名需要自己来命名】
【SQL语句并不区分大小写,但是一个文件名:在Windows下不区分大小写,但是在 Linux/UNIX下是区分大小写的】
【命名规则: 1、有意义(英文,英文组合或英文缩写)
2、自己定的名称最好小写。
3、SQL语句最好大写。】
1、 CREATE TABLE users(
id INT,
name CHAR(32)
);
2、 SHOW TABLES;
3、 DESC users;
4、 SELECT * FROM users;
二、数据值与列类型
都以空间大小来细分,能够存下即可!
1、数值型
整型(整数):
非常小整数型 1字节 -128~127 0~255(无符号) TINYINIT
较小整数型 2字节 -32768~32767 SMALLINIT
中等大小整数型 3字节 0~16777215 MEDIUMIINT
标准整数型 4字节 -2147483648~2147483647 INT
大整数型 8字节 BIGINT
【可以添加属性:UNSIGNED】
浮点型(小数):
FLOAT(M,N) 4字节 【长度M,保留小数点后N位】
DOUBLE(M,N) 8字节
DECIMAL(M,N) M+2字节 【定点数,以字符串形式存储数据, 更精确的保存数据,但是效率会有所折扣。】
【浮点数会存在误差,因此在对数字敏感的时候,需要用定点数来存储!】
2、字符型
MySQL支持以单引号与双引号表示字符串类型。
如 “MySQL” 与 'MySQL' 相同
char(M) 最大255 固定长度字符串
varchar(M) 最大255 可变长度字符串
char(4) varchar(4) // 永远比字符多一个字节
'' 4 '' 1字节
'a' 4 'a' 2字节
'abcd' 4 'abcd' 5字节
'abcdefg' 4 'abcdefgh' 5字节
char 类型会截取尾部的空格;
示例: CREATE TABLE IF NOT EXISTS tab(v varchar(4),c char(4));
INSERT INTO tab(v,c) VALUES(“ab ”,”ab ”);
SELECT CONCAT(v,”#”),CONCAT(c,”#”) FROM tab;
最佳实践:
固定长度,推荐使用char类型(可能会浪费一定空间)。
可变长度,推荐使用varchar类型(可能会付出一些性能损耗)
text 文本数据:文章,日志 长度:2^16 -1
MEDIUMTEXT
LONGTEXT
blob 二进制数据:照片,电影 长度:2^16 -1
MEDIUMBLOB
LONGBLOB
【虽然没法通过SQL语句将照片,电影,压缩包等二进制文件插入到数据库中, 但是我们可以通过C++/Java等编程语言将二进制文件读成二进制数据流,然 后保存到数据库中】
ENUM 枚举 1~2字节
ENUM(“one”,”two”,”three”,”four”)~65535
一次只能有一个值
SET 集合 1,2,3,4,8字节
SET(“one”,”two”,”three”,”four”)~64
一次可以有多个值,用“,”隔开。
3、日期型
DATE YYYY-MM-DD //如果位数充足,可以不用加‘-’
TIME hh:mm:ss //位数充足,可以忽略‘:’,位数不足,从后面截取
DATETIME YYYY-MM-DD hh:mm:ss
TIMESTAMP YYYYMMDDhhmmss //位数不足时,不可忽略前导0
YEAR YYYY
【创建数据表时,最好不要使用这些时间值,最好使用C++/Java等编程语言中的整数来保存 时间,这样更方便计算,如C++中的int,PHP中时间戳 1970-1-1 0:0:0】
bitsCN.com
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

AI Hentai Generator
Generate AI Hentai for free.

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

Imagine an artificial intelligence model that not only has the ability to surpass traditional computing, but also achieves more efficient performance at a lower cost. This is not science fiction, DeepSeek-V2[1], the world’s most powerful open source MoE model is here. DeepSeek-V2 is a powerful mixture of experts (MoE) language model with the characteristics of economical training and efficient inference. It consists of 236B parameters, 21B of which are used to activate each marker. Compared with DeepSeek67B, DeepSeek-V2 has stronger performance, while saving 42.5% of training costs, reducing KV cache by 93.3%, and increasing the maximum generation throughput to 5.76 times. DeepSeek is a company exploring general artificial intelligence

Boston Dynamics Atlas officially enters the era of electric robots! Yesterday, the hydraulic Atlas just "tearfully" withdrew from the stage of history. Today, Boston Dynamics announced that the electric Atlas is on the job. It seems that in the field of commercial humanoid robots, Boston Dynamics is determined to compete with Tesla. After the new video was released, it had already been viewed by more than one million people in just ten hours. The old people leave and new roles appear. This is a historical necessity. There is no doubt that this year is the explosive year of humanoid robots. Netizens commented: The advancement of robots has made this year's opening ceremony look like a human, and the degree of freedom is far greater than that of humans. But is this really not a horror movie? At the beginning of the video, Atlas is lying calmly on the ground, seemingly on his back. What follows is jaw-dropping

Earlier this month, researchers from MIT and other institutions proposed a very promising alternative to MLP - KAN. KAN outperforms MLP in terms of accuracy and interpretability. And it can outperform MLP running with a larger number of parameters with a very small number of parameters. For example, the authors stated that they used KAN to reproduce DeepMind's results with a smaller network and a higher degree of automation. Specifically, DeepMind's MLP has about 300,000 parameters, while KAN only has about 200 parameters. KAN has a strong mathematical foundation like MLP. MLP is based on the universal approximation theorem, while KAN is based on the Kolmogorov-Arnold representation theorem. As shown in the figure below, KAN has

AI is indeed changing mathematics. Recently, Tao Zhexuan, who has been paying close attention to this issue, forwarded the latest issue of "Bulletin of the American Mathematical Society" (Bulletin of the American Mathematical Society). Focusing on the topic "Will machines change mathematics?", many mathematicians expressed their opinions. The whole process was full of sparks, hardcore and exciting. The author has a strong lineup, including Fields Medal winner Akshay Venkatesh, Chinese mathematician Zheng Lejun, NYU computer scientist Ernest Davis and many other well-known scholars in the industry. The world of AI has changed dramatically. You know, many of these articles were submitted a year ago.

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

Target detection is a relatively mature problem in autonomous driving systems, among which pedestrian detection is one of the earliest algorithms to be deployed. Very comprehensive research has been carried out in most papers. However, distance perception using fisheye cameras for surround view is relatively less studied. Due to large radial distortion, standard bounding box representation is difficult to implement in fisheye cameras. To alleviate the above description, we explore extended bounding box, ellipse, and general polygon designs into polar/angular representations and define an instance segmentation mIOU metric to analyze these representations. The proposed model fisheyeDetNet with polygonal shape outperforms other models and simultaneously achieves 49.5% mAP on the Valeo fisheye camera dataset for autonomous driving

This paper explores the problem of accurately detecting objects from different viewing angles (such as perspective and bird's-eye view) in autonomous driving, especially how to effectively transform features from perspective (PV) to bird's-eye view (BEV) space. Transformation is implemented via the Visual Transformation (VT) module. Existing methods are broadly divided into two strategies: 2D to 3D and 3D to 2D conversion. 2D-to-3D methods improve dense 2D features by predicting depth probabilities, but the inherent uncertainty of depth predictions, especially in distant regions, may introduce inaccuracies. While 3D to 2D methods usually use 3D queries to sample 2D features and learn the attention weights of the correspondence between 3D and 2D features through a Transformer, which increases the computational and deployment time.
