From 7afc58562bc5347f20cc511eba52c373d1ebab51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=99=93=E5=BD=A4?= <11772389+hilda-chenxioatong@user.noreply.gitee.com> Date: Tue, 2 Jul 2024 08:16:09 +0000 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈晓彤 <11772389+hilda-chenxioatong@user.noreply.gitee.com> --- ...36\345\210\240\346\224\271\346\237\245.md" | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 "\351\231\210\346\231\223\345\275\244/20240702-\346\225\260\346\215\256\345\272\223\345\242\236\345\210\240\346\224\271\346\237\245.md" diff --git "a/\351\231\210\346\231\223\345\275\244/20240702-\346\225\260\346\215\256\345\272\223\345\242\236\345\210\240\346\224\271\346\237\245.md" "b/\351\231\210\346\231\223\345\275\244/20240702-\346\225\260\346\215\256\345\272\223\345\242\236\345\210\240\346\224\271\346\237\245.md" new file mode 100644 index 0000000..8eac80d --- /dev/null +++ "b/\351\231\210\346\231\223\345\275\244/20240702-\346\225\260\346\215\256\345\272\223\345\242\236\345\210\240\346\224\271\346\237\245.md" @@ -0,0 +1,67 @@ +## Linux 下数据库建库建表: + +创建:create database 库名 + +展示:show databases + +使用库:use 库名 + +删除库:drop database 库名 + +输入中文错误,英文成功? + +修改库字符集:alter database 库名 character set utf8 + +修改表字符集:alter table 表名 character set utf8 + +创建表: + +create table表名(int id primary key auto_increment,name varchar(225)) + +auto_increment : 自动递增 + +添加一条数控:insert into 表名 (id,name)values(1,'xiaoming') + +查看表内容:select * from 表名 + +查看表名中前两行内容:select * from 表名 order by id limit 0,2 + +删除表:drop table 表名 + +删除数据库指定的数据记录:delete from 表名 where id=4 (删除第四行) + +删除字段:alter table 表名 drop address + +本地使用数据库: + +查询数据库:show databases + +进入数据库: + +1. mysql -uroot -p '密码' + +2. mysql -uroot -p 出现Enter password + +查询数据表: + +use 数据库名 + +show tables + +查询数据 + +select name , age from 表名 where id=1; + +修改和更新: + +eg: insert into 表名(id,name,age)values(4,'lili',26) + +修改:update 表名 set name='zhangsan' where id =4 + +修改表名:alter table 表名 rename 新表名===>show tables==>select * from 新表名 + +添加字段:alter table 表名 add address varchar(50) default '地址不详' + +default 与 not null 配合使用 + +添加唯一键:alter table 表名 change name student_name varchar(20) unique key -- Gitee