数据库语句简单整理

1、创建表

stu 代表表名

sql = "Create table stu(id Integer,sex char,score float )";

  Integer 整形

2、插入数据

sql = "insert into stu(sex,score) values('man',98)";  //部分数据插入

sql = "insert into stu values(1,'man',99)"

3、更新数据

sql = "update stu set score = 99 where id = 1";

sql = "update stu set score = 99 ,sex = woman where id = 1";

4、查询数据

sql = "select * from stu";  //全部查询

sql = "select * from stu limit 100";  //查询最后100条数据

sql = "select * from stu where id = 1";  //按条件查询,此处是查询id为1的语句

sql = "select id from stu";  //查询id这一列的数据

5、删除语句

sql = "delete from stu where id = 1";  //删除id为1的这一行

sql = "delete from stu";  //删除整张表数据

6、在表中增加一列

sql = "alter table stu add column address char";  //在表中增加地址这一列

7、删除表

sql = "drop table stu";

猜你喜欢

转载自www.cnblogs.com/caozewen/p/12173865.html