当前位置: 代码迷 >> Sql Server >> 链表怎么存入数据库
  详细解决方案

链表怎么存入数据库

热度:67   发布时间:2016-04-24 08:55:54.0
链表如何存入数据库
各位大神,小弟的程序里有多个长链表,想实时保持到数据库内,当程序重启动时,从数据库恢复此链表.
但是思来想去,感觉自己设计不出来啊``该如何在链表节点操作,如何更改数据库.或者如何恢复.
求大家给点例子学习参考.
------解决思路----------------------

create table test(id int , previd int , nextid int , value varchar(10)) ;
go
insert into test values
(1,null,2,'A'),
(2,1,3,'B'),
(3,2,4,'C'),
(4,3,5,'D'),
(5,4,6,'E'),
(6,5,null,'F')
go
select * from test 
go
drop table test 
go

(6 行受影响)
id          previd      nextid      value
----------- ----------- ----------- ----------
1           NULL        2           A
2           1           3           B
3           2           4           C
4           3           5           D
5           4           6           E
6           5           NULL        F

(6 行受影响)


  相关解决方案