Chapter 2. Creating and Populating a Database
This chapter provides you with the information you need to create your first database and to create the tables and associated data used for the examples in this book. You will also learn about various data types and see how to create tables using them. Because the examples in this book are executed against a MySQL database, this chapter is somewhat skewed toward MySQL’s features and syntax, but most concepts are applicable to any server.
Creating a MySQL Database
If you want the ability to experiment with the data used for the examples in this book, you have two options:
- Download and install the MySQL server version 8.0 (or later) and load the Sakila example database from https://dev.mysql.com/doc/index-other.html.
- Go to https://learning.oreilly.com/scenarios/mysql-sandbox/9781492079705 to access the MySQL Sandbox, which has the Sakila Sample database loaded in a MySQL instance. If you don’t have one already, you’ll have to set up an O’Reilly account. Then, click on the Start button and begin.
If you choose the second option, once you start the scenario, a MySQL server is installed and started, and then the Sakila schema and data are loaded. When it’s ready, a standard mysql>
prompt appears, and you can then start querying the sample database. This is certainly the easiest option, and I anticipate that most readers will choose this option; if this sounds good to you, feel free to skip ahead to the next section.
If you prefer ...
Get Learning SQL, 3rd 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.