For the other columns, it??™s up to you to decide
which fields are required and which are not.
In some cases, instead of allowing NULLs, you??™ll prefer to specify default values. This
way, if the value is unspecified when creating a new row, it will be supplied with the default
value. The default value can be a literal value (such as 0 for a salary column or "unknown"
for a description column), a system value, or a function.
Autoincrement Columns
Autoincrement columns are automatically numbered columns. When a column is set as an
autoincrement column, MySQL automatically provides values for it when inserting new
records into the table. Usually if max is the largest value currently in the table for that column,
then the next generated value will be max + 1.
This way, the generated values are always unique, which makes them especially useful
when used in conjunction with the PRIMARY KEY constraint. You already know that primary
keys are used on columns that uniquely identify each row of a table. If you set a primary key
column to also be an autoincrement column, the MySQL server automatically fills that column
with values when adding new rows (in other words, it generates new IDs), ensuring that
the values are unique.
When setting an autoincrement column, the first value that the MySQL server provides
for that column is 1, but you can change this before adding data to your table with an SQL
statement like the following:
ALTER TABLE your_table_name AUTO_INCREMENT = 1234;
This way, your MySQL server will start generating values with 1234.
Pages:
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150