2015-12-08 80 views
2

我們的客戶端發送CSV文件(平均30萬條記錄)該文件。我們在我們的Microsoft SQL數據庫中導入。數據庫加密:MSSQL 2008+數據庫加密並在Coldfusion中使用

從CSV文件導入數據時有沒有辦法,我可以加密(SHA &其他)?如何發送查詢(選擇,插入&更新)到數據庫?從ColdfusionMicrosoft SQL

應用服務器:ColdFusion的9,9+和Lucee 數據庫:Microsoft SQL Server的2008+

對於實例IM已經使用mysql中。林在MSSQL尋找相同:

MYSQL例

INSERT:

INSERT INTO List_encrypted 
(fname,Lname,email) 
Values 
(AES_ENCRYPT(fname,'dbkey'), 
AES_ENCRYPT(Lname,'dbkey'), 
AES_ENCRYPT(email,'dbkey')) 
from List_encrypted 

SELECT

select CAST(AES_DECRYPT(fname,'dbkey')AS CHAR (50)) AS FirstName, 
CAST(AES_DECRYPT(Lname,'dbkey')AS CHAR (50)) AS LastName, 
CAST(AES_DECRYPT(email,'dbkey')AS CHAR (50)) AS email 
from List_encrypted 

MYSQL IMPORT CSV DATA

LOAD DATA LOCAL INFILE 'C:\filename.txt' 
INTO TABLE List_encrypted 
CHARACTER SET utf8 
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES 
(fname,lname,email,stamp_dt) 
SET 
fname = AES_ENCRYPT(@fname,'dbkey'), 
lname = AES_ENCRYPT(@lname,'dbkey'), 
email = AES_ENCRYPT(@email,'dbkey'), 
stamp_dt  = now(); 

這就是我所做的在MSSQL: 我不知道如何加密,而進口

CREATE TABLE List_encrypted 
(
ID int not null identity(1, 1) primary key, 
LName varchar(255), 
FName varchar(255), 
email varchar(255), 
); 

BULK INSERT [List_encrypted] 
FROM 'C:\filename.txt' 
WITH 
(
    FIELDTERMINATOR = '" ; "', 
    ROWTERMINATOR = '\r\n' 
) 
+0

您確定在*個人價值水平*上加密該數據庫首先是一個好主意嗎? – Tomalak

+0

@Tomalak爲什麼我要做一些領域,因爲這些是最重要的領域。最佳做法是什麼?你建議? – IBM

+0

通讀此拳頭:https://msdn.microsoft.com/en-us/library/bb510663(v=sql.110).aspx – Tomalak

回答

1

只有一個辦法,你可以在臨時表中批量導入然後是物理表。

示例:創建表

CREATE TABLE #t1 
(
    NAME varchar(255) 
); 

導入在臨時表

BULK INSERT [#t1] 
FROM 'C:\CSV\names.txt' 
WITH 
(
FIELDTERMINATOR = '" | "', 
ROWTERMINATOR = '\n' 
) 

導入在物理表& ENCRYPT

select 
    CAST(DECRYPTBYPASSPHRASE('dbkey',Encrypted) AS varchar(8000)) 
    AS Encrypted 
from t1 
+0

它的工作感謝,雖然我正在尋找其他東西似乎是這樣的解決方案。 – IBM