sql 语句 一

使用data

use mydata;

创建表
create table longmao
(
depeno int primary key,
dname varchar(20),
loc varchar(20)

);

往表里插数据

inseert into toroto values(1,'feifei');

显示所有的表

show tables;

显示表里的数据

select * from toroto;

left join

select * from t1 left join t2 on t1.id = t2.id;

right join

select * from t1 right join t2 on t1.id = t2.id;

显示所有的database

show databases;

显示表结构

desc toroto;

从第3行往后选一行

select * from toroto order by id desc limit 3,1;

删除表中的数据

delete from toroto;

删除表

drop table toroto;

auto_increment
create table toroto
(
id int primary key auto_increment,
name varchar(20)
);
null

insert into toroto values (null,'pangpang1');

只插name这一个元素

insert into toroto (name) values ('pangpang3');

显示当前时间

select now();

在name后面加一列home

alter table toroto add home varchar(100) after name;

删除home 这个字段

alter table toroto drop home;

把id为1的name替换成baobao

update toroto set name = 'baobao' where id = '1';

选出两张表中id相同的数据

select * from toroto,toroto2 where toroto.id = toroto2.id;

选出表中id=2的数据
select * from toroto where id = 2;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值