The basic operation of the database defined

First, relational and non-relational

  1. Relational databases: storage format can directly reflect the relationship between the entities . Relational databases and common form is quite similar to relational database tables between the table and there is a lot of complex relationships. Common relational databases have Mysql, SqlServer and so on.
  2. Non-relational databases: refers to the distributed, non-relational, not ensure compliance data storage systems ACID principles, such as MongoDB, Redis, Memcache . (ACID: atomicity, consistency, independence and persistence)

Second, the operation in the terminal database

  1. Log database
mysql -uroot -p123456
  1. (Sql statement requires a semicolon at the end) all database queries the database server
show databases;
  1. Select one database operations
use 数据库名;
  1. drop out
exit

Third, create a database table data

  1. Create a database
create database test;
  1. View data in the database table
show tables;
  1. Creating a data table
CREATE TABLE pet (
	name VARCHAR(20),
	owner VARCHAR(20),
	species VARCHAR(20),
	sex CHAR(1),
	birth DATE,
	death DATE);
  1. View data table structure
describe pet;

Fourth, the common data types

1. Value Type

2. Date / Time Types

Here Insert Picture Description

3. string type

Here Insert Picture Description

V. CRUD

  1. By INSERT
INSERT INTO pet VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
INSERT INTO pet VALUES ('狗蛋','刘景','狗','公','1989-03-30',NULL);
  1. 删 delete
delete from pet where name='Puffball';
  1. 改 update
update pet set name='旺财' where owner='刘景';
  1. Search select
select * from pet;
Published 60 original articles · won praise 6 · views 1209

Guess you like

Origin blog.csdn.net/DLC990319/article/details/105022455