A. 'char'

The correct answer is 'char'. Here's why:

  • 'char' is a data type in SQL designed specifically for storing fixed-length character strings. This means you define the maximum number of characters the field can hold, and the database will always allocate that amount of space, even if the actual data is shorter.

  • 'Fixedtext', 'Text', and 'mediumtext' are all data types for storing variable-length text. They don't have a fixed size limitation.

Example:

CREATE TABLE customers (
  name CHAR(50)
);

In this example, the name column will store a maximum of 50 characters, even if the actual name is shorter. If you insert a name with less than 50 characters, the remaining space will be padded with spaces.

Fixed Length Character Data Type: What to Use in SQL?

原文地址: https://www.cveoy.top/t/topic/nwVl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录