sql 語句 一,sql語句

來源:互聯網
上載者:User

sql 語句 一,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;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.