当前位置:网站首页>Some tips on learning database
Some tips on learning database
2022-07-04 10:58:00 【Black demon fairy moon】
database :
1. Concept : Storage , A warehouse for managing data .
2. Classification of database : Relational database , Non relational database .
MySQL:
1.SQL: Structured query language , Used to query , management , Update the program language of the database .
2. Common operation of database :
1). Common operation of database
Building database
create database fu_shi;
Query OK, 1 row affected (0.001 sec)
Delete library ( Use with caution )
MariaDB [(none)]> drop database cgb210901;
Query OK, 6 rows affected (0.112 sec)
View Library
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| fu_shi |
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.001 sec)
2) Common operations of tables
The creation of a table
MariaDB [(none)]> create table fu;
ERROR 1046 (3D000): No database selected
MariaDB [(none)]>
You can see , The code above is wrong , Bear in mind , When creating tables in a database, you must not directly create them without specifying the database . The correct way to create a table is as follows :
MariaDB [fu_shi]> use fu_shi;
Database changed
MariaDB [fu_shi]> create table fu(name varchar(100),age int(10),love varchar(100));
Query OK, 0 rows affected (0.022 sec)
Modify table ----> Add table fields
MariaDB [fu_shi]> alter table fu add column stud varchar (100);
Query OK, 0 rows affected (0.013 sec)
Delete table
MariaDB [fu_shi]> drop table fujia;
Query OK, 0 rows affected (0.018 sec)
View all tables
MariaDB [fu_shi]> show tables;
+------------------+
| Tables_in_fu_shi |
+------------------+
| fu |
+------------------+
1 row in set (0.001 sec)
View the structure of the table , That is, the fields of the table
MariaDB [fu_shi]> desc fu;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| name | varchar(100) | YES | | NULL | |
| age | int(10) | YES | | NULL | |
| love | varchar(100) | YES | | NULL | |
| stud | varchar(100) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
4 rows in set (0.007 sec)
3) Table records common operations :
insert record
MariaDB [fu_shi]> insert into fu values('fuhah',23,'szh','java');
Query OK, 1 row affected (0.007 sec)
Query log
MariaDB [fu_shi]> select * from fu;
+-------+------+------+------+
| name | age | love | stud |
+-------+------+------+------+
| fuhah | 23 | szh | java |
+-------+------+------+------+
1 row in set (0.000 sec)
Modify the record
MariaDB [fu_shi]> update fu set name='fuhaha';
Query OK, 1 row affected (0.007 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Delete record
MariaDB [fu_shi]> delete from fu ;
Query OK, 1 row affected (0.005 sec)
3. data type
a, Must start with a letter ;
b Different words are separated by underlining ;
c, Don't use keywords :where,group,order;
d,sql Case insensitive , In general ,mysql Use lowercase , Two Oracal Use uppercase
e, When naming, the length should not exceed 30 Characters ;
Naming rules
character
char: The length is immutable , But the reading speed is relatively fast
varchar: Variable length , But the reading speed is slow , More commonly used
Numbers
int ,tinyint: integer
double float: floating-point , But not exactly
numeric decimal: floating-point , Very precise
date :
date: Used to store hours, minutes and seconds
time: Used to store month, year and day
datetime: For MM DD YY , Minutes and seconds
timestamp: For from 1970.1.1.0:00 The number of milliseconds to the specified date
picture
blob Storage path , Not their own files
边栏推荐
- R built in data set
- What if the book written is too popular? Author of "deep reinforcement learning" at Peking University: then open the download
- Learning XML DOM -- a typical model for parsing XML documents
- TS type gymnastics: illustrating a complex advanced type
- Read a piece of text into the vector object, and each word is stored as an element in the vector. Convert each word in the vector object to uppercase letters. Output the converted elements in the vect
- The most ideal automated testing model, how to achieve layering of automated testing
- Fundamentals of software testing
- unit testing
- Write a program to define an array with 10 int elements, and take its position in the array as the initial value of each element.
- Summary of automated testing framework
猜你喜欢

Canoe the second simulation engineering xvehicle 3 CAPL programming (operation)

Introduction to Lichuang EDA

Digital simulation beauty match preparation -matlab basic operation No. 6

Canoe - the second simulation engineering - xvehicle - 2panel design (principle, idea)

Jemeter script recording

Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)

Quick sort (C language)
![[Galaxy Kirin V10] [server] NUMA Technology](/img/9b/65466c6fc6336e27e842f50c26b9c3.jpg)
[Galaxy Kirin V10] [server] NUMA Technology

JMeter correlation technology
![[Galaxy Kirin V10] [desktop] FTP common scene setup](/img/f6/e4fbfe69a6a7635ee6364114c46fd8.jpg)
[Galaxy Kirin V10] [desktop] FTP common scene setup
随机推荐
Linked list operation can never change without its roots
Usage of with as
Getting started with window functions
Canoe-the second simulation project-xvehicle-1 bus database design (idea)
Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)
Elevator dispatching (pairing project) ④
Article publishing experiment
[Galaxy Kirin V10] [server] KVM create Bridge
Discussion | has large AI become autonomous? Lecun, chief scientist of openai
software test
Get the data of the top 100 headlines today with Tianxing data
[Galaxy Kirin V10] [server] system startup failed
Replace() function
SSH原理和公钥认证
Learning XML DOM -- a typical model for parsing XML documents
[Galaxy Kirin V10] [server] NFS setup
[Galaxy Kirin V10] [desktop] printer
Function introduction of canbedded component
Canoe: distinguish VT, VN and vteststudio from their development history
Canoe - the second simulation engineering - xvehicle - 2panel design (principle, idea)