After you connect to the MySQL database, there may be several database operations available, so you need to select the database you want to manipulate.
Select the MySQL database from the command Prompt window
You can easily select a specific database in the Mysql> prompt window. You can use the SQL command to select the specified database.
Instance
The following instance selects the database tutorials:
[root@host]# mysql-u Root-p
After executing the above command, you have successfully selected the tutorials database, which will be executed in the tutorials database in subsequent operations.
Note: All database names, table names, and table fields are case-sensitive. So you need to enter the correct name when you use the SQL command.
Use PHP script to select MySQL database
PHP provides a function mysql_select_db to select a database. The function returns TRUE after successful execution, otherwise it returns FALSE.
Grammar
BOOL mysql_select_db (db_name, connection);
Instance
The following example shows how to use the mysql_select_db function to select a database:
Data type of Ps:mysql
the type of data field defined in MySQL is very important to optimize your database.
MySQL supports multiple types, roughly grouped into three categories: numeric, date/time, and string (character) types.
Numeric type
MySQL supports all standard SQL numeric data types.
These types include strict numeric data types (integers, SMALLINT, decimal, and numeric), and approximate numeric data types (FLOAT, real, and double PRECISION).
The keyword int is a synonym for integer, and the keyword Dec is synonymous with decimal.
Bit data types hold bit field values and support MyISAM, MEMORY, InnoDB, and BDB tables.
As an extension of the SQL standard, MySQL also supports integer types tinyint, Mediumint, and bigint. The following table shows the storage and scope of each integer type that is required.
Date and Time type
date and time types that represent time values are datetime, date, TIMESTAMP, times, and year.
Each time type has a valid range of values and a value of "0" that uses the "0" value when specifying a value that is not valid for MySQL to represent.
The timestamp type has proprietary automatic update attributes.
String type
string types refer to char, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, enum, and set. This section describes how these types work and how they are used in queries.
Char and varchar types are similar, but they are stored and retrieved in different ways. Their maximum length and whether the trailing spaces are retained are also different. No case conversion is made during storage or retrieval.
The binary and varbinary classes are similar to char and varchar, but they contain binary strings rather than binary strings. In other words, they contain a byte string instead of a character string. This means that they do not have a character set, and they sort and compare numeric values based on column-valued bytes.
A blob is a binary large object that can hold a variable number of data. There are 4 types of blobs: Tinyblob, BLOBs, Mediumblob, and Longblob. They are only the maximum lengths that can accommodate the values.
There are 4 types of text: Tinytext, text, Mediumtext, and Longtext. These correspond to 4 types of blobs, with the same maximum length and storage requirements.