移动表字段顺序,更改字段的属性

想要移动已建立的表的字段顺序,

If you want to modify a table property through the UI which requires a table recreation, then you need to change the following options in Management Studio:

Tools ->Options-> Designers -> Table and Database Designers -> uncheck the option "Prevent saving changes that require table re-creation"

想要更改字段的属性,变成int或者其他的,变成空或者非空,限制长度等,

ALTERTABLE mytable ALTER COLUMN name int NOT NULL

### 使用 ArcGIS 工具调整属性表字段顺序 在 ArcGIS 中,虽然没有直接提供用于修改字段顺序的功能,但可以通过特定工具间接实现这一目标。具体来说,利用 **要素类转要素类** 工具可以在处理过程中调整字段顺序[^5]。 #### 方法一:使用“要素类转要素类”工具 1. 在 ArcToolbox 中找到并启动 **要素类转要素类 (Feature Class to Feature Class)** 工具。 2. 设置输入要素类为需要调整字段顺序的目标数据集。 3. 配置输出位置以及输出文件名。 4. 关键在于配置【字段映射】选项卡内的参数: - 展开该部分后可以看到当前所有字段列表; - 选中想要重新排列的字段并通过右侧按钮控制其上下移动直至达到理想的位置关系; - 完成设置后执行转换操作即可获得具有新字段序列的新要素类实例。 这种方法不仅能够有效改变字段展示次序而且不会影响原有记录内容的一致性和完整性。 另外值得注意的是,如果仅仅是希望临时性地查看不同排序方式下的表格视图,则可以直接通过手动拖动列头的方式快速完成;不过这种方式仅适用于当前会话期间,并不具备持久化效果[^3]。 对于更复杂的情况还可以考虑采用其他高级方法如编写 Python 脚本来批量处理多个图层或大型地理数据库中的对象结构重组等问题。 ```python import arcpy def reorder_fields(input_feature_class, output_workspace, new_field_order): """Reorders fields of an input feature class and saves it as a new one.""" # Define the name for the output feature class based on the original plus "_reordered" fc_name = arcpy.Describe(input_feature_class).name out_fc = f"{output_workspace}\\{fc_name}_reordered" # Create field mappings object with reordered fields fm = arcpy.FieldMappings() for fld in new_field_order: mapping = arcpy.FieldMap() mapping.addInputField(input_feature_class, fld) fm.addFieldMap(mapping) # Perform conversion using updated field mappings arcpy.FeatureClassToFeatureClass_conversion( input_feature_class, output_workspace, fc_name + '_reordered', None, fm ) # Example usage input_fc = r"C:\path\to\your.gdb\featureclassname" new_order = ["FID", "Shape", "fieldA", "fieldB"] # Specify desired order here out_ws = r"C:\path\to\destination.gdb" reorder_fields(input_fc, out_ws, new_order) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值