SQL statement 1

Source: Internet
Author: User

SQL statement 1
Use data

Use mydata;

Create a table
Create table longmao
(
Depeno int primary key,
Dname varchar (20 ),
Loc varchar (20)

);

Insert data to the table

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

Show all tables

Show tables;

Show table data

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;

Show all databases

Show databases;

Display table structure

Desc toroto;

Select a row from row 3rd

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

Delete table data

Delete from toroto;

Delete table

Drop table toroto;

Auto_increment
Create table toroto
(
Id int primary key auto_increment,
Name varchar (20)
);
Null

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

Insert only the name Element

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

Show current time

Select now ();

Add a home column after name

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

Delete the home field

Alter table toroto drop home;

Replace the name with 1 with baobao

Update toroto set name = 'Bao' where id = '1 ';

Select the data with the same id in the two tables.

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

Select data with id = 2 in the table
Select * from toroto where id = 2;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.