Creating and modifying tables
Once the database is created, you want to start adding tables to it. You can, at any time, add new tables to the database and even add new fields to the tables. However, once applications are using your database, you should be very careful about removing or renaming procedures, views, tables, and fields because applications or MySQL views and procedures using these objects will stop working.
You can create a new table using the following command:
CREATE TABLE [IF NOT EXISTS] tableName (FieldName1 Datatype, FieldName2 Datatype, …)
There are a number of properties we can set when we add a field to a table. Before we move on to an example, let's briefly discuss the properties available for our fields. The first common type of property is to set controls for whether a field can be null or not. If a field should never be null, you can add NOT NULL
after the field data type. Otherwise, you can place NULL
after the data type to allow for...