如何截断访问表. [英] how to truncate table in access.

查看:60
本文介绍了如何截断访问表.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在访问中有一个表,它有一个自动编号字段.当我从excel导入数据时,我会删除此表中的所有数据并将excel中的数据插入到此表中,但是在自动编号字段中,它是从它的最后一个数字开始的.我想将其启动到1.我使用了truncate table命令,但在Access 2003中不起作用.

hello i have a table in access and it has a autonumber field. when i import data from excel than i delete all data from this table and insert data from excel to in this table but in autonumber field it start from it''s last number. i want to start it to 1. i have used truncate table command but it is not working in access 2003.

推荐答案

prosan,

我提到了您的问题,您尝试从表中删除所有记录,然后再次从0开始自动编号.
不能从0开始,否则可以删除表并重新创建它.因此您的删除和自动编号问题都将得到解决.
因为这是数据库的默认行为,即自动编号字段每次在插入记录时都会递增,因此用户无法设置它.

因此,您可以选择删除表并重新创建表,它将从0自动编号给出.


谢谢,
Nilesh
prosan,

i refer your problem, you attempting to delete all records from the table and again starts the autonumber from 0.
it is not possible to start from 0, other wise you can do delete the table and recreate it. so your problem of deleting and autonumber, both will be solved.
because, this is the default behaviour of the database for autonumber fields to increment every time when the record insert, it cannot be set by the user.

so, choice is yours either you delete the table and recreate the table , it will gives from the 0 autonumber.


thanks,
Nilesh


嗨Prosan,


是的,您可以使用查询在访问表中执行CRUD操作.

用于alter table字段:
Alter TABLE< tablename>更改<列名>计数器

这会将表字段更新为自动编号.

在这里,您会发现column数据类型将更改为AutoNumber.


有关更多信息,请访问 http://allenbrowne.com/func-DDL.html#CreateTableDDL [ ^ ]

谢谢,
Nilesh
hi Prosan,


yes, you can do CRUD operation in access tables using queries.

for alter table fields :
Alter TABLE <tablename> alter <columnname> COUNTER

This will update table fields to autonumber.

here, you will find the columns datatype will be change to AutoNumber.


for more information visit http://allenbrowne.com/func-DDL.html#CreateTableDDL[^]

Thanks,
Nilesh


您好,我找到了解决方案,现在我给了解决方案
首先删除所有数据,然后将该字段数据类型转换为数字,然后再将其数据类型转换为自动增量.这是一个简单的示例:-
从表名中
hello i have found the solution and now i am giving solution
first delete all data than convert this field datatype to number than again convert it datatype to autoincrement. here is simple example:-
delete from  TableName
alter table TableName alter column Id number  
alter table TableName alter column id AUTOINCREMENT


这篇关于如何截断访问表.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆