PLSQL 美化規則文件詳解


PL/SQL中有個代碼優化的功能,里面可以定義規則,挺好用的,跟大家分享下:

1.首先新建一個my.br文件,在文件中復制以下內容

復制代碼
Version=1
RightMargin=90
Indent=4
UseTabCharacter=FALSE
TabCharacterSize=4
AlignDeclarationGroups=TRUE
AlignAssignmentGroups=TRUE
KeywordCase=1
IdentifierCase=1
UseSpecialCase=TRUE
ItemList.Format=1
ItemList.Align=TRUE
ItemList.CommaAfter=TRUE
ItemList.AtLeftMargin=FALSE
EmptyLines=1
ThenOnNewLine=FALSE
LoopOnNewLine=FALSE
DML.LeftAlignKeywords=FALSE
DML.LeftAlignItems=FALSE
DML.OnOneLineIfPossible=TRUE
DML.WhereSplitAndOr=TRUE
DML.WhereAndOrAfterExpression=FALSE
DML.WhereAndOrUnderWhere=TRUE
DML.InsertItemList.Format=1
DML.InsertItemList.Align=FALSE
DML.InsertItemList.CommaAfter=TRUE
DML.InsertItemList.AtLeftMargin=FALSE
DML.SelectItemList.Format=1
DML.SelectItemList.Align=TRUE
DML.SelectItemList.CommaAfter=TRUE
DML.SelectItemList.AtLeftMargin=FALSE
DML.UpdateItemList.Format=0
DML.UpdateItemList.Align=FALSE
DML.UpdateItemList.CommaAfter=FALSE
DML.UpdateItemList.AtLeftMargin=FALSE
ParameterDeclarationList.Format=1
ParameterDeclarationList.Align=TRUE
ParameterDeclarationList.CommaAfter=TRUE
ParameterDeclarationList.AtLeftMargin=FALSE
RecordFieldList.Format=1
RecordFieldList.Align=TRUE
RecordFieldList.CommaAfter=TRUE
RecordFieldList.AtLeftMargin=FALSE
SplitAndOr=FALSE
AndOrAfterExpression=FALSE
[SpecialCase]
復制代碼

2.使用PLSQL,點擊PL/SQL Developer -> tools -> Preferences -> plsql beautifier -> rules file 將之前的文件載入進來,點擊應用即可

SQL美化前效果:

 

 

美化后的效果:

 

 

 

PS: 之前百度的時候,發現還有一個小技巧,也分享給大家

在上面DDL語句前后加上begin 和 end,哈哈,再美化下試試看,DDL被成功被美化了。

 

begin---①
create table student(
tid NUMBER(32) NOT NULL,
stu_name VARCHAR2(32),
stu_no VARCHAR2(64),
stu_sex char(1),
stu_age NUMBER(3)
);
end;--②

 

美化后的效果是:

 

BEGIN
---①
CREATE TABLE STUDENT(TID NUMBER(32) NOT NULL,
STU_NAME VARCHAR2(32),
STU_NO VARCHAR2(64),
STU_SEX CHAR(1),
STU_AGE NUMBER(3));
END; --②

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM