当前位置:网站首页>Day-27 database
Day-27 database
2022-07-03 18:35:00 【Xiaobai shelter】
First knowledge of database : Additions and deletions Example
Create a xiaoming user , Let Xiao Ming have the maximum authority ( and root equally )CREATE USER ‘username’@‘host’ IDENTIFIED BY ‘password’;
create user 'xiaoming'@'localhost'IDENTIFIED by '123';
Delete xiaoming user drop user user name @’%’;
drop user [email protected]'localhost';
# establish test database create database Database name
create database test;
# Delete test database
drop database test;
# establish Student list (student)
# Table has
id int
name varchar(30)
create table student(
id int,
name VARCHAR(30)
)
# Delete student surface
drop table student;
# Create a test_01 database , And create test_01 surface
Table has id , name , phone Please make rational use of data types
Add data to the table insert into Table name ( Name 1, Name 2) values ( value 1, value 2);
1 Zhang San 13113113111
# 2 Li Si 13213213222
# 3 Wang Wu 13313313333
hold id by 2 Of Phone changed to 13413413444
Delete id by 3 The record of
Query all remaining records
Delete test_01 Tables and databases
create database test_01;
create table test_0111123(
id int,
name VARCHAR(255),
phone CHAR(11)
)
INSERT into test_0111123 (id,name,phone) VALUES(1,' Zhang San ','13113113111');
INSERT into test_0111123 (id,name,phone) VALUES(2,' Li Si ','13113113222');
INSERT into test_0111123 (id,name,phone) VALUES(3,' Wang Wu ','13113113333');
#update Table name set Name 1= value , Name 2= value where Name = value ;
update test_0111123 set phone='13413413444' where id=2;
#delete from Table name where Name = value ;
delete from test_0111123 where id=3;
select * from test_0111123;
DROP table test_01;
DROP DATABASE test_01;
# Sign in test01 user , stay test_01 Create... Under database t_student surface , Table has id,name,sex,course,score
# among id yes int
name yes varchar
# sex yes char
# course yes varchar
# score yes decimal
towards t_student Insert in table 3 Data
1 Zhang San male javaSE 99
# 2 Li Si Woman javaWEB 98
3 Wang Wu male javEE 99.5
# stay test_01 Create... Under database t_student surface , Table has id,name,sex,course,score
use test_01;
create table t_student(
id int,
name VARCHAR(255),
sex VARCHAR(255),
course VARCHAR(255),
score DECIMAL(5,2)
)
drop table t_student;
# insert data
#insert into Table name ( Name 1, Name 2) values ( value 1, value 2);
insert into t_student(id,name,sex,course,score) VALUES(1,' Zhang San ',' male ','javaSE',99);
insert into t_student(id,name,sex,course,score) VALUES(2,' Li Si ',' Woman ','javaWEB',98);
insert into t_student(id,name,sex,course,score) VALUES(3,' Wang Wu ',' male ','javaEE',99.5);
# hold course by javaEE The scores of Change to 100 grammar :update Table name set Name 1= value , Name 2= value where Name = value ;
update t_student set score=100 where course='javaEE';
# hold Zhang San's gender is changed to Woman
update t_student set sex=‘ Woman ’ where name=‘ Zhang San ’;
# hold Wang Wu delete grammar : delete from Table name where Name = value ;
delete from t_student where name=‘ Wang Wu ’;
# hold t_student Table delete
drop table t_student;
# hold test_01 Database delete
drop database test_01;
# hold test01 User deletion ( Sign in root user ) drop user user name @’%’;
drop user [email protected]‘localhost’;
FLUSH PRIVILEGES;
边栏推荐
- Raft 日志复制
- Unsafe类的使用
- Sepconv (separable revolution) code recurrence
- Redis core technology and practice - learning notes (VII) sentinel mechanism
- What does foo mean in programming?
- Valentine's day, send you a little red flower~
- [untitled]
- Raft log replication
- Redis core technology and practice - learning notes (VI) how to achieve data consistency between master and slave Libraries
- 2022-2028 global aircraft head up display (HUD) industry research and trend analysis report
猜你喜欢
What kind of experience is it when the Institute earns 20000 yuan a month?
Implementation of cqrs architecture mode under Kratos microservice framework
SQL injection -day16
What London Silver Trading software supports multiple languages
Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
How to quickly view the inheritance methods of existing models in torchvision?
English grammar_ Noun classification
Read the paper glodyne global topology preserving dynamic network embedding
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
[Godot] add menu button
随机推荐
Usage of laravel conditional array in
12、 Service management
ES7 - Optimization of promise
On Data Mining
2022-2028 global lithium battery copper foil industry research and trend analysis report
简述服务量化分析体系
CV in transformer learning notes (continuously updated)
2022-2028 global marking ink industry research and trend analysis report
Win32: dump file analysis of heap corruption
图像24位深度转8位深度
PHP MySQL reads data
After nohup NPM start &, close the shell window directly, and the process closes accordingly
PHP MySQL order by keyword
Computer graduation design PHP campus address book telephone number inquiry system
Closure and closure function
Raft 日志复制
Raft log replication
2022-2028 global physiotherapy clinic industry research and trend analysis report
统计图像中各像素值的数量
Have you learned the correct expression posture of programmers on Valentine's day?