当前位置:网站首页>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
边栏推荐
- Introduction to canoe automatic test system
- Installation of ES plug-in in Google browser
- [Galaxy Kirin V10] [server] system startup failed
- Personal thoughts on the development of game automation protocol testing tool
- [advantages and disadvantages of outsourcing software development in 2022]
- Hidden C2 tunnel -- use of icmpsh of ICMP
- Dictionaries and collections
- regular expression
- Software testing related resources
- Quick sort (C language)
猜你喜欢
shell awk
[Galaxy Kirin V10] [desktop] can't be started or the screen is black
Add t more space to your computer (no need to add hard disk)
Elevator dispatching (pairing project) ③
Oracle11g | getting started with database. It's enough to read this 10000 word analysis
Quick sort (C language)
Unittest+airtest+beatiulreport combine the three to make a beautiful test report
Personal thoughts on the development of game automation protocol testing tool
[Galaxy Kirin V10] [server] soft RAID configuration
Network connection (III) functions and similarities and differences of hubs, switches and routers, routing tables and tables in switches, why do you need address translation and packet filtering?
随机推荐
Getting started with window functions
Hidden C2 tunnel -- use of icmpsh of ICMP
software test
本地Mysql忘记密码的修改方法(windows)
regular expression
Dichotomy search (C language)
/*Write a loop to output the elements of the list container in reverse order*/
Send a request using paste raw text
[Galaxy Kirin V10] [server] KVM create Bridge
Jemeter plug-in technology
XMIND installation
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.
Software testing related resources
Add t more space to your computer (no need to add hard disk)
Fundamentals of software testing
Open the neural network "black box"! Unveil the mystery of machine learning system with natural language
If function in SQL
Analysis function in SQL
2、 Operators and branches
F12 clear the cookies of the corresponding web address