SQL-基本增删改查

1.增——关键字 Insert

Insert into 表名 (列1,列2…) values (值1,值2…);
例如:

INSERT INTO test (NAME,age,phone ,record_time) VALUES ('Lily','14','13199999999','0019-04-23 00:00:00');
2.删——关键字 delete

delete from 表名 where 条件;
注意:在用delete的时候一定!一定!!要加条件!!!
例如:

DELETE FROM test WHERE NAME='Lily';
3.改——关键字 update

update 表名 set 列名1=值1,列名2=值2…where 条件;
例如:

UPDATE test SET age='15' , record_time='0019-04-23 05:00:00'    WHERE NAME='Lulu';
4.查——关键字 select

select * from 表名;
select * from 表名 where 条件;
select 列1,列2… 表名 where 条件;
例如:

select * from test;
select * from test where age >10;
select name,age,phone where age>10;
扩展 :

(1)关键字 limit (限制的条数)
select * from 表名 limit 行数;
例如:

 select * from test limit 1 ;

(2)关键字asc(升序)和desc(降序)

select * from 表名 order by 列名 asc;
select * from 表名 order by 列名 desc;

例如:

select * from test order by record_time asc;
select * from test order by record_time desc;

猜你喜欢

转载自blog.csdn.net/Q672405097/article/details/89710667