将大型阵列存储到一个桌子中,并在SQLite中使用10,000列

发布于 2025-01-31 22:18:37 字数 264 浏览 4 评论 0原文

我希望能够将一些100x100矩阵存储在数据库(协方差矩阵)中的表格上。对我来说,第一个好一步是将矩阵弄平并将矩阵结构(除其他事项)存储到父表中。

但是,创建这样的表格将需要制作一个大约10,000列的表。编写如此多的字段名称会使我的SQL代码非常大,如果我想查询该矩阵,我将不知道从哪里开始。

是否有一种整洁的方法可以在SQL中指定此类表?我是否可以使用这样的表格从数据库中设置或获取特定(矩阵)(矩阵集)的整洁方法?有更好的方法吗?

我正在使用SQLite作为数据库。

I want to be able to store some 100x100 matrices onto a table within my database (covariance matrices). A first good step for me would be to flatten the matrix and store the matrix structure (among other things) into a parent table.

However, creating such a table would require to make a table with about 10,000 or so columns. Writing so many field names would make my SQL code extraordinarily large, and I wouldn't know where to start if I want to query for that matrix.

Is there a neat way to specify such a table in SQL? Is there a neat way for me to set or get a particular (set of) matrix (matrices) from my database using such a table? Is there a better way?

I am using Sqlite for my databases.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

像极了他 2025-02-07 22:18:37

所有具有相同类型列的大尺寸的表都可以旋转。

例如,如果您的表格有这样的表格:

row   col1   col2    col3 ...
1     1      2       3
2     11     12      13

旋转带有3个colums的表

row   col   value
1     1     1
1     2     2
1     3     3
2     1     11
2     2     12
2     3     13

简单地

select col1, col2, col3 ...... from A where row = 2

可以

select value from A where row = 2 order by col

您 处理。

All tables with big size of same typed columns can be rotated.

For example if you have a table A like this:

row   col1   col2    col3 ...
1     1      2       3
2     11     12      13

You can simply rotate to a table with 3 colums

row   col   value
1     1     1
1     2     2
1     3     3
2     1     11
2     2     12
2     3     13

so instead of writing big sql like

select col1, col2, col3 ...... from A where row = 2

you write sql like

select value from A where row = 2 order by col

the result set was originally horizontal and now become vertical -- it is rotated and easy to handle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文