sql / beginner
Snippet
Defining Variable-Length Text with the VARCHAR Data Type
The VARCHAR data type stores variable-length character strings up to a defined maximum length. It conserves storage space when entries vary in length.
snippet.sql
sql
1
2
3
CREATE TABLE users (username VARCHAR(50));
Breakdown
1
CREATE TABLE users (
Initiates the creation of a new database table named 'users'.
2
username VARCHAR(50)
Defines a column 'username' that holds up to 50 text characters.
3
);
Closes the table definition statement.