首页 小组 文章 相册 留言本 用户 搜索 我的社区 在线学堂 商城 购物车 支付钱包

[打卡]5月28号打卡

2024-05-28 10:23:45
0
173

#AUTO_
create database dbtest;
use dbtest;
select database();
create table test1(
id int primary key AUTO_INCREMENT,last_name varchar(15));

desc test1;
insert into test1
(last_name)
values
('Sam');

select * from test1;

insert into test1
(id,last_name)
values
(0,'Tom');

insert into test1
(id,last_name)
values
(null,'Lili');

insert into test1
(id,last_name)
values
(null,'Lili');

#开发中,一旦主键作用的字段上声明有自增列时,则我们在添加数据时,就不要给主键对应的字段去赋值

insert into test1
(id,last_name)
values
(-20,'lucy');

#在alter table 时添加自增列(很少)

create table test2(
id int primary key,
last_name varchar(10));

desc test2;

alter table test2
modify id int AUTO_INCREMENT;

#在alter table 时删除自增列

ALTER table

alter table test2
modify id int;

use atguigudb;
#查询和Zlotkey相同部门的员工姓名和工资
select last_name,salary
from employees
where department_id in(
select department_id
from employees
where last_name = 'Zlotkey');

#查询工资比公司平均工资高的员工的员工号。姓名和工资

select employee_id,last_name,salary
from employees
where salary > (
select AVG(salary)
from employees
);
















评论
意见反馈