In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The basic concept of database
Data:
Symbolic records that describe things are called data (Data), including numbers, text, graphics, images, sounds, archives, etc., stored in a unified format in the form of "records".
Table:
By organizing different records together, the "table" is used to store specific data.
Database:
A database is a collection of tables, a warehouse that stores data and stores interrelated data in a certain organizational manner. today's mainstream database introduces SQL_Server (Microsoft) for Windows operating system simple, easy to use Oracle (Oracle products) for all mainstream platforms safe, perfect, complex operation DB2 (IBM products) for all mainstream platforms large, secure Improve MySQL (acquired by Oracle) free, open source, small relational database
Relational database system is a database system based on relational model, and its basic concept comes from relational model.
The relational model is based on the theory of relational algebra. The data structure uses a simple and understandable two-dimensional data table, which can be directly represented by a simple "entity-relation" (Emurr) diagram.
The Emurr diagram contains three elements: entities (data objects), relationships and attributes.
Entity:
Also known as an example, corresponding to "events" or "things" that can be distinguished from other objects in the real world, such as bank customers, bank accounts, etc.
Attributes:
A characteristic of an entity that an entity can have more than one attribute. For example, each entity in the "bank customer" entity set has attributes such as name, address, telephone number, etc.
Contact:
The correspondence between entity sets becomes a relationship, also known as a relationship. For example, there is a "savings" relationship between bank customers and bank accounts.
The collection of all entities and their relationships forms a relational database
Relational database understanding
The storage structure of a relational database is a two-dimensional table, and the data that reflects things and their relationships is saved in the form of a table. in each two-dimensional table, each row is called a record, which is used to describe the information of an object, and each column is called a field. used to describe an attribute of an object
Introduction to non-relational database
Non-relational database, also known as NoSQL (Not Only SQL), stores data without a relational model and does not require a fixed table format.
As a supplement to relational database, non-relational database plays an important role in high efficiency and high performance in the increasingly rapid development of the website era.
Advantages of non-relational databases:
The requirement of high concurrent read and write in database
Efficient storage and access to massive data
Requirements for high scalability and high availability of database
Non-relational database storage mode key-value mode (key-value), key-based storage, delete, change data column storage (Column-oriented), store related data in column family files, database is composed of a series of data items, each data item has a name and corresponding value graphic mode, entity is vertex, relation is edge, data is saved as a graphic non-relational database product Memcached is an open source A high-performance cache system with distributed memory objects that stores data cache data in key-value to reduce database pressure and speed up access. Dynamic web application cache content is stored in memory Redis is also a way to store data in key-value, data is also stored in memory However, periodically writing data to disk has the following characteristics compared to Mencached: support for memory caching, support for persistent data types, and more support for clusters. Distributed support queue Redis application example: database front-end cache session sharing when you need to cache more data types than key/value, when the cached data needs to be saved for a long time, MySQL database introduction MySQL is a popular open source relational database Oracle products comply with the GPL protocol Free trial and modification features: excellent performance, stable open source service, no copyright restrictions, low cost and multithreading. Multi-users view database list information [root@localhost] # mysql-uroot-p # # enter the database Enter password:.. MySQL > show databases based on the basic operation command of secure and reliable database based on Cramp S (client / server) architecture. +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ 4 rows in set (0.00 sec) View the data table information in the database mysql > use mysql # # using database Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changedmysql > show tables # # View the table in the library +-+ | Tables_in_mysql | +-+ | columns_priv | | db displays the structure of the data table (field) mysql > desc user # # display the structure of the data table +-- +-+ | Field | | Type | Null | Key | Default | Extra | + -+-+ | Host | char (60) | NO | PRI | User | char (10) | NO | PRI | binary search takes a data as a reference The smaller ones on the left and the bigger ones on the right.
Summary of SQL sentences SQL language is an acronym for Structured Query Language, that is, structured query language is a standard language for relational databases to maintain and manage databases, such as data query, data update, access control, object management and other functions SQL classification DDL: data definition language DML: data manipulation language DQL: data query language DCL: data control language DDL statement operation DDL statement is used to create database objects, such as libraries, tables Indexes, etc., use DDL statements to create a new library, table mysql > create database test # # create database Query OK, 1 row affected (0.00 sec) mysql > use test; # # use database Database changedmysql > create table info (# # create table-> ID int (3) not null,-> name varchar (5) not null,-> address varchar (10) not null,-> score decimal default 0,-> primary key (ID); mysql > desc info # # View table structure +-+ | Field | Type | Null | Key | Default | Extra | +-+ -+-+ | ID | int (3) | NO | PRI | NULL | | name | varchar (5) | NO | | NULL | | address | varchar (10) | NO | | NULL | | score | decimal (1010) | YES | 0 | | +- -+-+ 4 rows in set (0.01 sec) DML statement operation inserts a new data record into the data table mysql > insert into info values (1 A few rounds of the week, Nanjing, 80) # # insert data Query OK, 1 row affected (0.00 sec) mysql > insert into info values (2 row affected 'Wang Feng', 'Nanjing', 0); Query OK, 1 row affected (0 sec) mysql > insert into info values (3 Query OK'Na Ying', 'Beijing', default); Query OK, 1 row affected (0.01 sec) to update the data record mysql > update info set address = 'Shanghai' where ID=1 in the database table # # modify the data Query OK in the table, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 delete the specified data record mysql > delete from info where ID=2; # # delete the specified data record Query OK in the table, 1 row affected (0.00 sec) mysql > select * from info # # View the contents of the table (DQL statement) +-+ | ID | name | address | score | +-+ | 1 | Round of the week | Shanghai | 80 | | 3 | Na Ying | Beijing | 0 | +-+ 2 rows in set (0.00 sec) mysql > drop table info # # delete table Query OK, 0 rows affected (0.00 sec) mysql > show tables; # # View table Empty set (0.00 sec) mysql > drop database test; # # Delete library Query OK, 0 rows affected (0.00 sec) mysql > show databases # # View library +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | +-+ 4 rows in set (0.00 sec) DQL statement operation
DQL is a data query statement with only one item: select
Used to find qualified data records from the data table
No conditions can be specified when querying
Mysql > select * from info # # View the contents of the table +-+ | ID | name | address | score | +-+ | 1 | Round of the week | Shanghai | 80 | | 3 | Na Ying | | Beijing | 0 | +-+ 2 rows in set (0.00 sec) |
Specify conditions when querying
Mysql > select address from info where address = 'Beijing'; # # View specified conditions +-+ | address | +-+ | Beijing | +-+ 1 row in set (0.00 sec) DCL language operation # # set user permissions (if the user does not exist, then the new user) mysql > grant all privileges on *. * to 'root'@'%' identified by' abc123' Query OK, 0 rows affected, 1 warning (0.00 sec) # # View the user's permissions mysql > show grants for 'root'@'%' +-+ | Grants for root@% | +-- + | GRANT ALL PRIVILEGES ON *. * TO 'root'@' %'| +-- + 1 row in set (0.00 sec) # # revoke the user's permissions mysql > revoke all on *. * from 'root'@'%' Query OK, 0 rows affected (0 sec) Thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.