sqlserver用sql来操作数据库

来源:互联网 发布:axentwear淘宝 编辑:程序博客网 时间:2024/06/05 05:30

01:创建一个数据库:create database db_test;

02:使用某个数据库:use db_test;

03:创建表:

create table t_test(id int primary key,name varchar(11),age int);


04:往数据表中增加记录:

insert t_test(id) values(1); insert t_test(id,name) values(2,'test2'); insert t_test(id,name,age) values(3,'test3',30); 

05:更新数据表中的记录:

update t_test set name='test1',age=10 where id=1;update t_test set age=20 where id=2;

06:删除数据表中记录:

delete t_test where id=3;


07:查询数据表中的记录:

select id,name,age from t_test;


注:查询的时候,一般不写select * from,原因是,select * from语句,如果数据表中新增了字段,程序将会出错。


最基本的操作就写到这里,实际开发中这些最基本的也是最实用的东西。



0 0
原创粉丝点击