UTF-8 Unicode (with BOM), resulting in SQL script execution error
For the differences between BOM with and without BOM, let's take a look at the discussion above.
Link: What is the difference between BOM-free UTF-8 and BOM-free UTF-8?
During recent development, SQL Files written in windows always report errors when executed in linux.
At the beginning of the file, whether it is to use Chinese or English comments, or even remove the comments, will also report SP2-0734: unknown command beginning "? Declare... "-restofline ignored. Error.
The following is the initial part of the file.
- --create tablespace
- declare
- v_tbs_name varchar2(200):='hytpdtsmsshistorydb';
- begin
The following error is reported:
- SP2-0734: unknown command beginning "?--create ..." - rest of line ignored.
- PL/SQL procedure successfully completed.
I have not found a solution to this problem on the Internet, and the file encoding has been changed to UTF-8.
Finally, check the difference between BOM and no BOM. If you try to change it to no BOM, there will be no errors.
Check the file encoding. The difference between a normal file and an error file is: with BOM
- [oracle@localhost Oracle_proc]$ file *
- bill_query_proc.sql: UTF-8 Unicode C program text
- crt_tab_hytpdtsmsshistorydb.sql: UTF-8 Unicode(with BOM)text
You can modify the encoding type of a file in two ways:
1. Use VI to modify the file encoding type
: Set encoding = UTF-8
: Set nobom
2. Use ultraedit in windows and save it as a UTF-8-No BOM
After the modification is completed, both Chinese and English are used, or annotations are removed.