Managing Databases and Tables
In this section, we use the MySQL command interpreter to create databases and tables using the winestore database as a case study. We also show you the statements that remove databases and tables.
A discussion of advanced features is in Chapter 15. We show you how to manage indexes and alter tables after they've been created, and delete and update data using queries and multiple tables. We also show you how the details of how to store multiple statements in a file and execute them; this is how we created our winestore script that you used in the installation steps in Appendix A through Appendix C.
Creating Databases
The CREATE DATABASE
statement creates a new, empty database without any
tables or data. The following statement creates a database called
winestore:
mysql>CREATE DATABASE winestore;
A database name can be 64 characters in length at most and can contain any character except the forward slash, backward slash, or period characters.
Database and table names are used as the disk file names that store the data. Therefore, if your operating system has case-sensitive filenames, MySQL is case-sensitive to database and table names; in general, Unix platforms are case sensitive and Microsoft Windows platforms aren't. Attribute names are not case sensitive on all platforms. Aliases (which are discussed in Chapter 15) are partially case sensitive: table aliases follow the same rule as table names (and so are case sensitive on some platforms), while attribute ...
Get Web Database Applications with PHP and MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.