Skip to Content
MySQL Cookbook, 3rd Edition
book

MySQL Cookbook, 3rd Edition

by Paul DuBois
August 2014
Intermediate to advanced
866 pages
24h 4m
English
O'Reilly Media, Inc.
Content preview from MySQL Cookbook, 3rd Edition

Chapter 10. Working with Metadata

Introduction

Most of the SQL statements used so far have been written to work with the data stored in the database. That is, after all, what the database is designed to hold. But sometimes you need more than just data values. You need information that characterizes or describes those values—that is, the statement metadata. Metadata is used most often to process result sets, but also applies to other aspects of your interaction with MySQL. This chapter describes how to obtain and use several types of metadata:

Information about statement results

For statements that delete or update rows, you can determine how many rows were changed. For a SELECT statement, you can obtain the number of columns in the result set, as well as information about each column in the result set, such as the column name and its display width. For example, to format a tabular display, you can determine how wide to make each column and whether to justify values to the left or right.

Information about databases and tables

A MySQL server can be queried to determine which databases and tables it manages, which is useful for existence tests or producing lists. For example, an application might present a display enabling the user to select one of the available databases. Table metadata can be examined to determine column definitions; for example, to determine the legal values for ENUM or SET columns to generate web form elements corresponding to the available choices.

Information about ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

MySQL Cookbook, 4th Edition

MySQL Cookbook, 4th Edition

Sveta Smirnova, Alkin Tezuysal
SQL Cookbook, 2nd Edition

SQL Cookbook, 2nd Edition

Anthony Molinaro, Robert de Graaf

Publisher Resources

ISBN: 9781449374112Errata PageSupplemental Content