Your cart is currently empty!
Category: mariadb
-
Khóa học miễn phí MariaDB – Select Database nhận dự án làm có lương
MariaDB – Select Database
After connecting to MariaDB, you must select a database to work with because many databases may exist. There are two ways to perform this task: from the command prompt or through a PHP script.
The Command Prompt
In choosing a database at the command prompt, simply utilize the SQL command ‘use’ −
[root@host]# mysql -u root -p Enter password:****** mysql> use PRODUCTS; Database changed mysql> SELECT database(); +-------------------------+ | Database | +-------------------------+ | PRODUCTS | +-------------------------+
Once you select a database, all subsequent commands will operate on the chosen database.
Note − All names (e.g., database, table, fields) are case sensitive. Ensure commands conform to the proper case.
PHP Select Database Script
PHP provides the mysql_select_db function for database selection. The function uses two parameters, one optional, and returns a value of “true” on successful selection, or false on failure.
Syntax
Review the following select database script syntax.
bool mysql_select_db( db_name, connection );
The description of the parameters is given below −
S.No Parameter & Description 1 db_name
This required parameter specifies the name of the database to use.
2 connection
When not specified, this optional parameter uses the most recent connection used.
Try the following example code for selecting a database −
<html> <head> <title>Select a MariaDB Database</title> </head> <body> <?php $dbhost = ''localhost:3036 $dbuser = ''guest1 $dbpass = ''guest1a $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die(''Could not connect: '' . mysql_error()); } echo ''Connected successfully mysql_select_db( ''PRODUCTS'' ); mysql_close($conn); ?> </body> </html>
On successful selection, you will see the following output −
mysql> Connected successfully
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc
Khóa học miễn phí MariaDB – Home nhận dự án làm có lương

MariaDB Tutorial
MariaDB is a fork of the MySQL relational database management system. The original developers of MySQL created MariaDB after concerns raised by Oracle”s acquisition of MySQL. This tutorial will provide a quick introduction to MariaDB, and aid you in achieving a high level of comfort with MariaDB programming and administration.
Audience
This tutorial targets novice developers and those new to MariaDB. It guides them in understanding basic through more advanced concepts in MariaDB. After completing this tutorial, your firm foundation in MariaDB and level of expertise will allow you to begin developing and easily build on your knowledge.
Prerequisites
The tutorial assumes your familiarity with relational database management systems, querying languages, MySQL, and general programming. It also assumes familiarity with typical database operations in an application.
Khóa học lập trình tại Toidayhoc vừa học vừa làm dự án vừa nhận lương: Khóa học lập trình nhận lương tại trung tâm Toidayhoc