Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of mysql database (based on ubuntu 14.0.4 LTS 64-bit)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The composition and related Concepts of 1.mysql Database

First of all, I understand that mysql is a relational database, and the biggest difference between a relational database and a non-relational database is that the concept of tables is different.

+ the whole mysql environment can be understood as the largest database: a

+ Database B created with mysql belongs to An and is a data warehouse, which is equivalent to a folder in the system.

+ Datasheet C: it is the specific place where data is stored, which is equivalent to the files in the system. A database B contains several datasheets C (note that database B is different from A here)

Record D: a row in a data table is called a record, so when we create a data table, we must create an id column to identify "which record is this". The value of the id column cannot be the same and must be unique, just like the ID number. There can be multiple records D in a table C

+ Field E: each column in a table is called "field". Every field in the database is defined, such as the data type of the field, the judgment of empty and non-empty, automatic growth, and so on. A record D can have multiple fields E.

+ data F: the intersection of rows and columns is the real "data" F.

two。 Database basic operations (ubuntu environment) commonly used command examples.

2.1Log in mysql:mysql-uroot-p-u: login with user name,-p: enter password

2.2 View the database: after entering the above command, you will be asked to enter a password, and after a successful login, the interface shown above will be displayed to view the data B that comes with system A.

Showdatabases; note that the semicolon should not be reduced, as shown in the following figure of the database that comes with the system.

2.3.Create the database: create database mytest; thus creates a database B called mytest.

2.4 in the above four databases, how to select the database we want? Usemytest, which selects our database mytest.

2.5 if you want to delete the database: dropdatabasemytest will delete the database without reminding you.

2.6 View current status: status

2.7 there are two ways to display table C in the current database. A show table, a picture, a picture. Where mytest is the database we set up.

2.8 Establishment and deletion of data tables

Createtablemytable (idint,nameint)

Droptablemytable

2.9 how to use the established data table, that is, how to insert data into the data table? Insertintomytable (id,name) values (1Mar 10)

2.10 query table data, selectid,namefrommytablewhereid=1order; or select*frommytable

2.11 data updates in the table, update mytable set name=20 where id=1

2.12 Table deletion: deletefrommytable; or droptablemytable

2.13 Modification of table structure

(1) add a field format:

Altertabletable_nameaddcolumn (field name field type);-- this method is parenthesized

(2) specify the location where the field is inserted:

Altertabletable_nameaddcolumn field name field type after a field

(3) modify field name / type

Altertabletable_namechange old field name new field name type of new field

(4) change the name of the table

Altertabletable_namerenametonew_table_name

(5) clear all the data in the table at once

Truncatetabletable_name; this method also causes the number taker (ID) in the table to start at 1

(6) Delete a field:

Altertabletable_namedrop field name

2.14 modify password format: mysqladmin-u username-p old password password new password

2.15 shows the structure of the table: describemytables

2.16 displays the current database and user show database (); show user ()

3 Note:

3.1 if you enter the order and find that you forgot to add the semicolon, you don't have to type the command again, just enter the semicolon.

3.2 you can use the cursor up and down keys to call up the previous command.

Summary

The above is the whole content of this article about the detailed explanation of mysql database (based on ubuntu 14.0.4 LTS 64-bit). I hope it will be helpful to you. Interested friends can refer to other related topics on this site, if there are any deficiencies, please leave a message to point out. Thank you for your support to this site!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report