當前位置:首頁 » 編程語言 » 批量修改sql文件字元集
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

批量修改sql文件字元集

發布時間: 2022-05-28 12:50:26

『壹』 sql 批量修改數據

使用update 更新修改資料庫數據,更改的結果集是多條數據則為批量修改。
語法格式如:
update 表格 set 列 = 更改值 where 篩選條件
例:
update table set a=1 --將table 中所以a列的值改為 1
update table set a=1 where b=2 --將table 中列b=2的記錄中a列的值改為 1

『貳』 SQL 欄位值批量修改

1.篩選?

where
語句
2.同時減去一個固定值
set
列名=列名-固定值
update語句
例如:
表名
table1
欄位名
field1
(int)
篩選
>
10
減去一個固定值
-
2
sql語句:
update
table1
set
field1=field1-2
where
field1>10

『叄』 sql 怎樣批量修改欄位的首個字元

表為AB,欄位為cd
sql語句如下:
update AB set cd = replace(cd,'8K','AK') where cd like '8K%'
如果欄位中有可能有多個8K
update AB set cd= case when left(cd,2)='8K' then 'AK'+right(cd,len(cd)-2) else cd end

『肆』 sql 語句 批量修改

update 表名
set C_METHOD_NAME= lower(substring(REPLACE(C_METHOD_NAME,'process',''),1,1))+
substring(REPLACE(C_METHOD_NAME,'process',''),2,len(REPLACE(C_METHOD_NAME,'process','')))
--REPLACE(C_METHOD_NAME,'process','')用空值取代process
-- lower改小寫
--lower(substring(REPLACE(C_METHOD_NAME,'process',''),1,1))把取代後字元串的第一個字母改小寫
--再加上後面的字元串

『伍』 sql怎麼批量替換欄位里的字元串的

方法一:
varchar和nvarchar類型是支持replace,所以如果你的text不超過8000可以先轉換成前面兩種類型再使用replace 替換 text ntext 數據類型欄位的語句 。

update表名set欄位名=replace(cast(與前面一樣的欄位名asvarchar(8000)),'原本內容','想要替換成什麼')

方法二:

update[表名]set欄位名=replace(與前面一樣的欄位名,'原本內容','想要替換成什麼')

『陸』 怎樣用SQL語句批量修改字元串中指定位置的字元

--假如修改第10位的字元
update 表名 set 欄位名=left(欄位名,9) + '要替換成的內容' + substring(欄位名,11,len(欄位名))

『柒』 sql語句進行批量修改

修改語句 update hstlst set h_hmedir='e:\'+SUBSTRING (h_hmedir, 4, len(h_hmedir)-3)where left(h_hmedir,3)='d:\'涉及知識:Update更改表中的現有數據SET指定要更新的列或變數名稱的列表SUBSTRING返回字元、binary、text 或 image 表達式的一部分語法SUBSTRING ( expression , start , length )expression是字元串、二進制字元串、text、image、列或包含列的表達式。不要使用包含聚合函數的表達式。start是一個整數,指定子串的開始位置。length是一個整數,指定子串的長度(要返回的字元數或位元組數)。LEFT返回從字元串左邊開始指定個數的字元。語法LEFT ( character_expression , integer_expression ) 參數character_expression字元或二進制數據表達式。character_expression 可以是常量、變數或列。character_expression 必須是可以隱式地轉換為 varchar 的數據類型。否則,請使用 CAST 函數顯式轉換 character_expression。integer_expression是正整數。如果 integer_expression 為負,則返回空字元串。返回類型varchar愛上網iSuNet論壇謝謝您的支持,轉載請帶本帖地址:[url]http://www.ningood.com/viewthread.php?tid=5638&fromuid=0[/url]

『捌』 sql批量修改欄位

通過存儲過程來實現,方法說明:
1、建一個臨時表用於存放表名和欄位名;
2、在系統表中查看有該欄位的所有表,存入臨時表
3、在臨時表建游標,逐條執行修改;
4、刪除臨時表。

CREATE PROCEDURE Rename
@databaseName varchar(500),
@oldName varchar(500),
@newName varchar(500)
AS
create table #temp(tablename varchar(200),columnName varchar(200))
declare @tableName_cursor varchar(200)
declare @colName_cursor varchar(200)
declare @objName varchar(200)
declare @tableName varchar(200),@colName varchar(200)
exec('declare tableName_cursor cursor for select name from '+@databaseName+'.dbo.sysobjects where xtype=''u'' and status >= 0')
open tableName_cursor
fetch next from tableName_cursor into @tableName_cursor
while @@fetch_status = 0
begin
insert into #temp select @tableName_cursor,name from syscolumns where id = object_id(@tableName_cursor)
fetch next from tableName_cursor into @tableName_cursor
end
close tableName_cursor
deallocate tableName_cursor

declare col_cursor cursor for select columnName from #temp
open col_cursor
fetch next from col_cursor into @colName_cursor
while @@fetch_status = 0
begin
if @colName_cursor = @oldName
begin
select @tableName=tableName,@colName=columnName from #temp where columnName = @colName_cursor
set @objName = @tableName+'.'+@colName
exec sp_rename @objName,@newName,'Column'
end
fetch next from col_cursor into @colName_cursor
end
close col_cursor
deallocate col_cursor

select * from #temp where columnName = 'isdeleted' or columnName = 'isdatadeleted'
drop table #temp
GO

exec rename @databaseName='test',@oldName='isdeleted',@newName = 'isdatadeleted'

drop PROCEDURE rename

『玖』 關於sql語句如何批量修改數據。

update 分析表 set 調味品='t' where 流水號 in (select 流水號 from 銷售表 where 大類名稱='調味品')
你欄位太多,一句sql只能改一個分類
你就把分類多換幾次執行吧

『拾』 MySQL資料庫,如何批量替換整個資料庫的個別字元

用phpmyadmin把資料庫導出為.sql腳本,空間商一般有提供這個管理工具給用戶使用的,如果沒提供,你也可以自行上傳一個到空間里。用它導出為.sql腳本後,用記事本打開,然後用一次性查找替換,替換之後保存,然後再在phpmyadmin里把原來的表及數據全部刪除,刪除後重新導入修改好的.sql腳本。

操作以上東西時請先備份你的資料庫喔,以免有意想不到的問題發生。