当前位置:网站首页>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
边栏推荐
- 20 kinds of hardware engineers must be aware of basic components | the latest update to 8.13
- Appscan installation steps
- 本地Mysql忘记密码的修改方法(windows)
- Add t more space to your computer (no need to add hard disk)
- The last month before a game goes online
- Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)
- Canoe - description of common database attributes
- JMeter correlation technology
- DNS hijacking
- Fundamentals of database operation
猜你喜欢

Function introduction of canbedded component

Analysis function in SQL

SQL greatest() function instance detailed example
![[Galaxy Kirin V10] [desktop] can't be started or the screen is black](/img/68/735d80c648f4a8635513894c473860.jpg)
[Galaxy Kirin V10] [desktop] can't be started or the screen is black

Send a request using paste raw text

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

shell awk

Appscan installation steps
![[Galaxy Kirin V10] [server] NUMA Technology](/img/9b/65466c6fc6336e27e842f50c26b9c3.jpg)
[Galaxy Kirin V10] [server] NUMA Technology
![[Galaxy Kirin V10] [desktop] printer](/img/ab/066923f1aa1e8dd8dcc572cb60a25d.jpg)
[Galaxy Kirin V10] [desktop] printer
随机推荐
Send a request using paste raw text
[Galaxy Kirin V10] [desktop and server] FRP intranet penetration
Canoe: what is vtsystem
CAPL: on sysVar_ Update difference on sysvar
Iterator generators and modules
Using Lua to realize 99 multiplication table
Canoe the second simulation engineering xvehicle 3 CAPL programming (operation)
Communication layer of csframework
Write a program that uses pointers to set all elements of an int array to 4.18: 0.
Getting started with window functions
三立期货安全么?期货开户怎么开?目前期货手续费怎么降低?
Canoe: the difference between environment variables and system variables
Introduction to tree and binary tree
Huge number (C language)
If function in SQL
JMeter correlation technology
[Galaxy Kirin V10] [server] iSCSI deployment
Canoe - the third simulation project - bus simulation-1 overview
XMIND installation
Capl: timer event