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;