MariaDB Crash Course - Ben Forta [0]
Ben Forta
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Cape Town • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419
corpsales@pearsontechgroup.com
For sales outside the United States, please contact:
International Sales
international@pearson.com
Visit us on the Web: informit.com/aw
Editor-in-Chief
Mark Taub
Acquisitions Editor
Mark Taber
Managing Editor
Kristy Hart
Project Editors
Elaine Wiley
Jovana San Nicolas-Shirley
Copy Editor
Geneil Breeze
Indexer
Erika Millen
Proofreader
Leslie Joseph
Publishing Coordinator
Vanessa Evans
Book Designer
Gary Adair
Compositor
Gloria Schurick
Library of Congress Cataloging-in-Publication Data
Forta, Ben.
MariaDB crash course / Ben Forta.
p. cm.
Includes index.
ISBN 978-0-321-79994-4 (pbk.)
1. MariaDB. 2. Database management. 3. Client/server computing. I. Title.
QA76.9.D3F663 2012
004’.36--dc23
2011023506
Copyright © 2012 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey 07458, or you may fax your request to (201) 236-3290.
ISBN-13: 978-0-321-79994-4
ISBN-10: 0-321-79994-1
Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana.
First printing September 2011
Table of Contents
Introduction
What Is MariaDB Crash Course?
Who Is This Book For?
Companion Web Site
Conventions Used in This Book
1: Understanding SQL
Database Basics
What Is a Database?
Tables
Columns and Datatypes
Rows
NULL
Primary Keys
What Is SQL?
Try It Yourself
Summary
2: Introducing MariaDB
What Is MariaDB?
Client-Server Software
MySQL Compatibility
MariaDB Tools
mysql Command Line
MySQL Workbench
Summary
3: Working with MariaDB
Making the Connection
Selecting a Database
Learning About Databases and Tables
Summary
4: Retrieving Data
The SELECT Statement
Retrieving Individual Columns
Retrieving Multiple Columns
Retrieving All Columns
Retrieving Distinct Rows
Limiting Results
Using Fully Qualified Table Names
Using Comments
Summary
5: Sorting Retrieved Data
Sorting Data
Sorting by Multiple Columns
Specifying Sort Direction
Summary
6: Filtering Data
Using the WHERE Clause
The WHERE Clause Operators
Checking Against a Single Value
Checking for Nonmatches
Checking for a Range of Values
Checking for No Value
Summary
7: Advanced Data Filtering
Combining WHERE Clauses
Using the AND Operator
Using the OR Operator
Understanding Order of Evaluation
Using the IN Operator
Using the NOT