Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

18.4 Create databases and forms


May 24, 2021 That's what Linux should learn



In the MariaDB database management system, a database can hold multiple data tables, and data forms are the most important and core content in the database. W e can customize the database table structure to our own needs, and then store the data in it reasonably so that it can be easily maintained and modified later. Table 18-2 lists the database commands that will be used later and the corresponding effects.

Table 18-2 is used to create the database's commands and roles

Usage Act CREATE database database name. C reate a new database DESCRIBE form name; D escribes the form UPDATE form name SET attribute, the new value WHERE attribute, the original value; U pdate the name of the data USE database in the form; T he database SHOW databases specified for use; S how show tables of databases that are currently existing; D isplays the name of the form selected in the current database, FROM form; S elect a record value from the form DELETE FROM form name WHERE attribute value; R emoving a record value from a form Establishing a database is the starting point for managing data. Now try to create a database called linuxprobe, and then look at the database list, and you'll see it:

MariaDB [(none)]> CREATE DATABASE linuxprobe; Q uery OK, 1 row affected (0.00 sec) MariaDB [(none)]> SHOW databases; + --------------------+ | D atabase | + --------------------+ | i nformation_schema | | l inuxprobe | | m ysql | | p erformance_schema | T o -------------------- form, you need to switch to a specified database to create a data form. F or example, create a form mybook in a new linuxprobe database, and then initialize the form, which defines the structure that stores the data content. W e define three field items, where the 15-character character field name is used to hold the book name, and the integer field price and pages store the book's price and page number, respectively. You can see the structure of the form after you have executed the following commands:

MariaDB [(none)]> use linuxprobe; D atabase changed MariaDB [linuxprobe]> CREATE TABLE mybook (name char(15),price int,pages int); Q uery OK, 0 rows affected (0.16 sec) MariaDB [linuxprobe]> DESCRIBE mybook; + -------+----------+------+-----+---------+-------+ | F ield | T ype | N ull | K ey | D efault | E xtra | + -------+----------+------+-----+---------+-------+ | n ame | c har(15) | Y ES | | N ULL | | | p rice | i nt(11) | Y ES | | N ULL | | | p ages | i nt(11) | Y ES | | N ULL | | +-------+----------+------+-----+---------+-------+ 3 rows in set (0.02 sec)