Skip to content

CHAR

CREATE TABLE test (
column_test CHAR(5)
);
INSERT INTO test(column_test)
VALUES ('abc');
SELECT * FROM test;
column_test
abc

In this example, a table named ‘test’ is created with a column ‘column_test’ which has the CHAR data type of length 5. The CHAR data type is a fixed length string data type, meaning that it will always use the same amount of storage space regardless of the length of data inserted. If the data inserted (‘abc’) is shorter than the declared length (5), the remaining space will be filled with blank spaces. When retrieved with a SELECT statement, ‘abc’ is displayed.