using data
Use MyData;
Create a table
CREATE TABLE Longmao
(
Depeno int PRIMARY KEY,
Dname varchar (20),
Loc varchar (20)
);
inserting data into the table
Inseert into Toroto values (1, ' Feifei ');
Show all the tables
Show tables;
Show data in table
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 the database
show databases;
Show Table structure
Desc Toroto;
Select a row from line 3rd
SELECT * from Toroto ORDER BY id DESC limit 3, 1;
Delete Data from a table
Delete from Toroto;
Delete a 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 of this element
Insert into Toroto (name) VALUES (' Pangpang3 ');
Show Current time
Select Now ();
add a column to the home after name
ALTER TABLE Toroto Add home varchar (+) after name;
Delete Home This field
ALTER TABLE Toroto drop home;
replace name with ID 1 to Baobao
Update Toroto Set name = ' Baobao ' WHERE id = ' 1 ';
Select two tables with the same ID data
SELECT * from Toroto,toroto2 where toroto.id = toroto2.id;
Select the id=2 data in the table
SELECT * from Toroto where id = 2;
SQL statement One