后端基础(全是精华版)

3 篇文章 0 订阅
1 篇文章 0 订阅

后端基础

web访问:

服务端:访问网页的服务器(中间件)

客户端:浏览器

登陆mysql命令行指令:mysql -u root -p

密码:root

三种sql语句

  • DDL:数据定义语言(创建,删除,修改数据的语言)

    • create:创建数据库或表等对象
    • drop:删除数据库或表等对象
    • alter:修改数据库或表等对象
  • DML:数据操作语句(查询或修改表中的记录)

    • insert:向表中插入数据
    • select:查询表中的数据
    • update:修改表中的数据
    • delete:删除表中的数据
  • DCL:数据控制语言(不会用到前期)

数据库操作语言(database_name指数据库的名称)
  • create database database_name;

    • 创建新的数据库
  • show databases;

    • 查看所有的数据库
  • drop database database_name;

    • 删除数据库
  • use database_name;

    • 进入数据库

所有操作语句的最后都要添加分号;
😀

查看数据库的语句database是复数要加s
😀

show databases
😀

数据库中表的操作语言
  • create table table_name(column_name column_typle);

  • eg: create table information_person(id int,name varchar(20));

    • 例子解释:上述指令中创建了一个名为information_person的表,information_person的表中创建了两个表头分别是整数类型的id和字符串类型的name
  • show tables;

  • 显示所有所在库中的所有表

  • desc table_name;

  • 查看指定表(table_name)中的所有信息
    column_typle是指数据的类型(数据的类型分两种分别是:int整数和varchar字符串)

  • alter table table_name drop column_name;

    • eg:alter person_information drop id;
    • 例子解释:上述的指令中删除了在person_information表中的id字段
  • alter table table_name change column_name other_column_name column_typle;

    • eg:alter table person_information change id age int;
    • 例子解释:在person_information表中将id字段改写为age字段类型为整数int
数据库中对表中数据的操作(数据这里简写成information)
  • insert into table_name values(‘information1’,‘information2’);
  • insert into table_name (meter1,meter2) values (information1,information2);
    • Eg:insert into person_information (name,age) value (Harry,12);
    • 例子解释:向名字为person_information的表中将Harry和12分别插入到name和age的为表头的行列中
    • 这里information1和information2都为varchar类型要加单引号,整数类型和浮点数类型不需要添加,在这里information1是插入在第一个字段名下,information2插入在第二个字段名下
  • select*from table_name;
    • 查询指定表(table_name)下所对应的字段名和数据关系
    • eg:select*from person_information;
    • 这里的*表示在person_information表中所有的值
  • Update table_name set colu mn_name=value
    • Eg: update person_information set name=NULL;
    • 例子解释:将person_information这张表中的所有的name下的数据改为NULL(无)
  • where 字段=字段值
    • Eg:update person_information set name=NULL where id=0 or id=-1;
    • Or = and
    • 例子解释:在person_information这张表中将name下数据中满足id=1或id=-1的值变为NULL(无)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值