加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sqlserver用sql来操作数据库

发布时间:2020-12-12 13:27:56 所属栏目:MsSql教程 来源:网络整理
导读: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) valu

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,age from t_test;


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


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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读