当前位置:网站首页>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
边栏推荐
- 本地Mysql忘记密码的修改方法(windows)[通俗易懂]
- 2022 ape circle recruitment project (software development)
- Network connection (II) three handshakes, four waves, socket essence, packaging of network packets, TCP header, IP header, ACK confirmation, sliding window, results of network packets, working mode of
- Usage of with as
- Write a program to judge whether the elements contained in a vector < int> container are 9.20: exactly the same as those in a list < int> container.
- [Galaxy Kirin V10] [server] NFS setup
- Hidden C2 tunnel -- use of icmpsh of ICMP
- Collection of practical string functions
- Personal thoughts on the development of game automation protocol testing tool
- unit testing
猜你喜欢
Canoe - the second simulation engineering - xvehicle - 2panel design (principle, idea)
Collection of practical string functions
Replace() function
How do microservices aggregate API documents? This wave of show~
Network connection (II) three handshakes, four waves, socket essence, packaging of network packets, TCP header, IP header, ACK confirmation, sliding window, results of network packets, working mode of
[Galaxy Kirin V10] [server] NFS setup
[Galaxy Kirin V10] [desktop] printer
Article publishing experiment
Ten key performance indicators of software applications
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
随机推荐
51 data analysis post
Heartbeat启动后无反应
On binary tree (C language)
Canoe: what is vtsystem
Interview and lecture summary 1
Deepmind proposed a Zuan AI, which specially outputs network attack language
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Replace() function
Design and common methods of test case documents
Virtual machine configuration network
iptables导致Heartbeat脑裂
3W word will help you master the C language as soon as you get started - the latest update is up to 5.22
Knapsack problem and 0-1 knapsack problem
/*Rewrite the program, find the value of the element, and return the iterator 9.13: pointing to the found element. Make sure that the program works correctly when the element you are looking for does
VPS安装Virtualmin面板
TS type gymnastics: illustrating a complex advanced type
Elevator dispatching (pairing project) ③
Strings and characters
Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)
Performance test method