CCSID
내가 해야 할 일은 이 파일 내에서 검색하여 찾은 모든 것입니다. CCSID
해당 CHAR
줄의 은 로 바뀌고 해당 줄 NCHAR
의 VARCHAR
는 으로 바뀌어야 합니다 NVARCHAR2
.
sed와 awk를 사용해 보았습니다. 하지만 이 문제에 대한 완벽한 해결책을 찾을 수 없습니다.
CREATE TABLE JCR.ICMSTSYSCONTROL (
LIBRARYSERVERID INTEGER NOT NULL ,
LANGUAGECODE CHAR(3) CCSID 37 NOT NULL ,
SYSSEGMENTID SMALLINT NOT NULL ,
SYSSEGMENTTHRESHLD INTEGER NOT NULL ,
ACLBINDINGLEVEL SMALLINT NOT NULL ,
LIBRARYACLCODE INTEGER NOT NULL ,
PUBACCESSENABLED SMALLINT NOT NULL ,
DFLTACLCHOICE SMALLINT NOT NULL ,
SMSCHOICE SMALLINT NOT NULL ,
TRACELEVEL SMALLINT NOT NULL ,
MAXUSERS INTEGER NOT NULL ,
MAXUSERACTION SMALLINT NOT NULL ,
CURRENTUSERS INTEGER NOT NULL ,
MAXLOGONRETRY SMALLINT NOT NULL ,
PASSWORDDURATION SMALLINT NOT NULL ,
SYSADMINEVENTFLAG SMALLINT NOT NULL ,
SYSTEMFLAG SMALLINT NOT NULL ,
DATABASETYPE SMALLINT NOT NULL ,
MAXTXDURATION INTEGER NOT NULL ,
MAXRESULTSETSIZE INTEGER NOT NULL ,
ALLOWTRUSTEDLOGON SMALLINT NOT NULL ,
DOCROUTINGUPDATE INTEGER NOT NULL ,
DOCROUTINGFREQ SMALLINT NOT NULL ,
PLATFORM SMALLINT NOT NULL ,
SYSTIMEOUT SMALLINT NOT NULL ,
TIEUSERID CHAR(175) CCSID 37 DEFAULT NULL ,
TIEPASSWORD CHAR(72) FOR BIT DATA DEFAULT NULL ,
DATABASENAME VARCHAR(128) CCSID 37 NOT NULL ,
DBSCHEMANAME VARCHAR(128) CCSID 37 NOT NULL ,
TRACEFILENAME VARCHAR(128) CCSID 37 DEFAULT NULL ,
ENCRYPTIONKEY VARCHAR(128) FOR BIT DATA NOT NULL ,
KEEPTRACEOPEN SMALLINT NOT NULL ,
MULTIPLETRACEFILES SMALLINT NOT NULL ,
MAXTRACEFILESIZE INTEGER NOT NULL ,
PATHICMROOT VARCHAR(128) CCSID 37 NOT NULL ,
PATHICMDLL VARCHAR(128) CCSID 37 NOT NULL ,
SUSPENDSERVERTIME TIMESTAMP DEFAULT NULL ,
RMSTATUSINTERVAL SMALLINT NOT NULL ,
RMSTATUSTIMEOUT SMALLINT NOT NULL ,
TIEINTERVAL SMALLINT NOT NULL ,
LSCURRENTVERSION VARCHAR(128) CCSID 37 NOT NULL ,
TRACEUSER CHAR(175) CCSID 37 DEFAULT NULL ,
DIMSGDIGESTALGO SMALLINT NOT NULL DEFAULT 0 ,
DIENCRYPTIONALGO SMALLINT NOT NULL DEFAULT 0 ,
CONSTRAINT JCR.ICMSTSYSCONTROLPK PRIMARY KEY( LIBRARYSERVERID ) )
;
출력은 다음과 같아야 합니다.
CREATE TABLE JCR.ICMSTSYSCONTROL (
LIBRARYSERVERID INTEGER NOT NULL ,
LANGUAGECODE NCHAR(3) CCSID 37 NOT NULL ,
SYSSEGMENTID SMALLINT NOT NULL ,
SYSSEGMENTTHRESHLD INTEGER NOT NULL ,
ACLBINDINGLEVEL SMALLINT NOT NULL ,
LIBRARYACLCODE INTEGER NOT NULL ,
PUBACCESSENABLED SMALLINT NOT NULL ,
DFLTACLCHOICE SMALLINT NOT NULL ,
SMSCHOICE SMALLINT NOT NULL ,
TRACELEVEL SMALLINT NOT NULL ,
MAXUSERS INTEGER NOT NULL ,
MAXUSERACTION SMALLINT NOT NULL ,
CURRENTUSERS INTEGER NOT NULL ,
MAXLOGONRETRY SMALLINT NOT NULL ,
PASSWORDDURATION SMALLINT NOT NULL ,
SYSADMINEVENTFLAG SMALLINT NOT NULL ,
SYSTEMFLAG SMALLINT NOT NULL ,
DATABASETYPE SMALLINT NOT NULL ,
MAXTXDURATION INTEGER NOT NULL ,
MAXRESULTSETSIZE INTEGER NOT NULL ,
ALLOWTRUSTEDLOGON SMALLINT NOT NULL ,
DOCROUTINGUPDATE INTEGER NOT NULL ,
DOCROUTINGFREQ SMALLINT NOT NULL ,
PLATFORM SMALLINT NOT NULL ,
SYSTIMEOUT SMALLINT NOT NULL ,
TIEUSERID NCHAR(175) CCSID 37 DEFAULT NULL ,
TIEPASSWORD CHAR(72) FOR BIT DATA DEFAULT NULL ,
DATABASENAME NVARCHAR2(128) CCSID 37 NOT NULL ,
DBSCHEMANAME NVARCHAR2(128) CCSID 37 NOT NULL ,
TRACEFILENAME NVARCHAR2(128) CCSID 37 DEFAULT NULL ,
ENCRYPTIONKEY VARCHAR(128) FOR BIT DATA NOT NULL ,
KEEPTRACEOPEN SMALLINT NOT NULL ,
MULTIPLETRACEFILES SMALLINT NOT NULL ,
MAXTRACEFILESIZE INTEGER NOT NULL ,
PATHICMROOT NVARCHAR2(128) CCSID 37 NOT NULL ,
PATHICMDLL NVARCHAR2(128) CCSID 37 NOT NULL ,
SUSPENDSERVERTIME TIMESTAMP DEFAULT NULL ,
RMSTATUSINTERVAL SMALLINT NOT NULL ,
RMSTATUSTIMEOUT SMALLINT NOT NULL ,
TIEINTERVAL SMALLINT NOT NULL ,
LSCURRENTVERSION NVARCHAR2(128) CCSID 37 NOT NULL ,
TRACEUSER NCHAR(175) CCSID 37 DEFAULT NULL ,
DIMSGDIGESTALGO SMALLINT NOT NULL DEFAULT 0 ,
DIENCRYPTIONALGO SMALLINT NOT NULL DEFAULT 0 ,
CONSTRAINT JCR.ICMSTSYSCONTROLPK PRIMARY KEY( LIBRARYSERVERID ) )
;
이 문제를 어떻게 해결하나요?
답변1
그리고 sed
:
sed '/CCSID/ { s/ CHAR(/ NCHAR(/; s/ VARCHAR(/ NVARCHAR2(/ }' file
- 첫 번째 패턴은
CCSID
. 그런 다음 내부 부분이{...}
적용됩니다.s/ CHAR(/ NCHAR(/;
CHAR(
(선행 공백 포함)을 로 바꾸십시오NCHAR(
.s/ VARCHAR(/ NVARCHAR2(/
VARCHAR(
로 대체되었습니다NVARCHAR2(
.
답변2
perl -pe '/CCSID/ and s/\bCHAR\b/N$&/ || s/\bVARCHAR\b/N$&2(/' file