创建表:
create table 表名(
列名 字段长度
)
create table testsix(
bookno char(20),
bookname char(20),
name char(20)
time char(20)
timetwo char(20)
);
增加一些字段数据:
insert into 表名 (字段1, 字段2) values (值1, 值2);
insert into testfive (‘id’,‘name’) values(‘1’,‘3’);
增加全部字段数据:
insert into 表名values (值1, 值2);
insert into testfive values(‘1’,‘3’,‘33’,‘333’);
insert into testfive values(‘2’,‘web’,‘湖中大’,‘学习’);
insert into testfive values(‘3’,‘数据库’,‘北大’,‘学习’);
insert into testfive values(‘3’,‘数据库’,‘北大’,‘学习’);
查看表的所有属性:
select * from testfour;
有条件的查看表的所有属性:
select * from testfour where id=‘1’;
有条件的删除数据:
delete from testthree where bookno=1;
String sql =“delete from test where username=’” + username + “’”;
直接删除表中的数据
delete from testthree;
或者
truncate testthree;
修改数据:
update testthree set bookname=2,bookpublic=3,booktype=4 where bookno=1;
String sql =“update testthree set bookname=’” + bookname + “’ , bookpublic=’” + bookpublic + “’ , booktype=’” + booktype + “’ where bookno=’” + bookno + “’”;
上面所有的例子全是以代码为例写的。
要是在数据库的增删改查,就需要对表名等信息加上英文的双引号。