Database Basic Concept Literacy:
What is a database? a database is a warehouse that organizes, stores, and manages data according to its structure, and each database has one or more different APIs for creating, accessing, managing, searching, and replicating the saved data; we can also store the data in a file, However, it is relatively slow to read and write data in the file, so now we use the relational database management system (RDBMS) to store and manage the large amount of data, so-called relational database is based on the relational model of the database, with the help of Set algebra and other mathematical concepts and methods to process the data in the database. The RDBMS is the feature of the relational database management system (relational Management Systems): 1the data appears in tabular form.2. Each record name of each behavior3data fields for each column record name4. Many rows and columns form a single sheet5. A number of forms make up databaseRDBMS terminology before we begin to learn MySQL database, let us first understand some of the terms of the following RDBMS: database: database is a collection of related tables; data tables: A table is a matrix of data. A table in a database looks like a simple spreadsheet; columns: a column (a data element) that contains the same data,For example, data for postal codes; line: one row (=A tuple, or record) is a set of related data, such as a user's subscribed data; redundancy: storage twice times the data, redundancy can make the system faster; PRIMARY key: The primary key is unique, a data table can contain only one primary key, you can use the primary key to query the data; foreign Key: The foreign key is used to correlate two tables; composite key: composite key (key combination) multiple columns as an index key, typically used for composite indexes; index: use an index to quickly access specific information in a database table. An index is a structure that sorts the values of one or more columns in a database table. A directory similar to a book; referential integrity: referential integrity requires that references to non-existent entities are not allowed in the relationship. and entity integrity are the integrity constraints that the relational model must satisfy in order to ensure the consistency of the data. MySQL Database MySQL is a relational database management system developed by the Swedish MySQL AB company, currently owned by Oracle Corporation. MySQL is an associated database management system that keeps data in separate tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility. 1.Mysql is open source, so you don't have to pay an extra fee; 2.Mysql supports large databases. Large databases with thousands records can be processed, 3.MySQL uses standard SQL data language forms, 4.Mysql can be allowed on multiple systems, and supports multiple languages, including C, C + +, Python, Java, Perl, PHP, Eiffel, Ruby and Tcl, etc., 5.Mysql is very good support for PHP, PHP is currently the most popular web development language, 6.MySQL support large database, support 50 million records of Data Warehouse, 32-bit system table file can support 4GB, 64-bit system supports the largest table file is 8TB, 7.Mysql can be customized, using the GPL protocol, you can modify the source code to develop their own MySQL system.
syntax: command with semicolon ";" End
Display database:mysql> showdatebases;
Create databases:mysql> CREATE database databasename;
Enter the database:mysql> use Databasesname;
Display Data sheet:mysql> show tables; # after entering a database
To create a data table:
Mysql> Create DatabaseBookstore; # Create a bookstore database Query OK,1Row affected (0.00sec) MySQL> UseBookstore; # using the bookstore database DatabaseChangedmysql>Show tables; EmptySet(0.00sec) MySQL> Create TableBooks ( #创建books, 3 columns of Books information table -book_idINT, -TitleVARCHAR( -), -AuthorVARCHAR( -)); Query OK,0Rows Affected (0.05sec)
MySQL>show tables;# Display data table for bookstore database+---------------------+|Tables_in_bookstore|+---------------------+|Books|+---------------------+1Rowinch Set(0.00sec) MySQL>describe books; # Display Books Data Sheet +---------+-------------+------+-----+---------+-------+|Field|Type| Null | Key | Default |Extra|+---------+-------------+------+-----+---------+-------+|book_id| int( One)|YES| | NULL | ||Title| varchar( -)|YES| | NULL | ||Author| varchar( -)|YES| | NULL | |+---------+-------------+------+-----+---------+-------+3Rowsinch Set(0.00Sec
To back up the database: [Email protected]~]mysqldump-u username-p "password" databasename > databasename.sql; # no spaces between-p and password
MySQL Learning notes