O'Reilly logo

Managing & Using MySQL, 2nd Edition by Hugh E. Williams, Randy Yarger, George Reese, Tim King

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data Types

The MySQL C API uses several defined data types beyond the standard C types. These types are defined in the mysql.h header file that must be included when compiling any program that uses the MySQL library.

MYSQL

A structure representing a connection to the database server. The program allocates a variable of this type, initializes the variable through the mysql_init call, and passes the variable to subsequent calls. The elements of the structure contain the name of the current database and information about the client connection, among other things.

MYSQL_FIELD

A structure containing all the information concerning a specific field in the table. Of all the types created for MySQL, this is the only one with member variables accessed directly from client programs. Therefore, you need to know the layout of the structure:

char *name

The name of the field.

char *table

The name of the table containing this field. For result sets that do not correspond to real tables, this value is null.

char *def

The default value of this field, if one exists. This value is always null unless mysql_list_fields is called, after which it is the correct value for fields that have defaults.

enum enum_field_types type

The type of the field. The type is one of the internal MySQL SQL data types. The following field types (along with their corresponding common MySQL SQL data types) are currently defined:

  • FIELD_TYPE_TINY (TINYINT )

  • FIELD_TYPE_SHORT (SMALLINT )

  • FIELD_TYPE_LONG (INTEGER ) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required