[root@localhost bin]# ./disql SYSDBA/SYSDBA@localhost:5236
./disql SYSDBA/Yt#75Usky@localhost:5237
./disql SYSDBA/'"Yt#75Usky"'@localhost:5237
./disql usky_cloud/'"Yt#75Usky"'@localhost:5237
151:
./disql usky-cloud/usky666888@localhost:5236
./disql usky-fire/usky888666@localhost:5236
./dbca.sh
cd dmdbms/bin
CREATE TABLESPACE dem_enforce_project_all
DATAFILE '/home/dm8/data/usky_fire/dem_enforce_project_all.dbf' SIZE 256 AUTOEXTEND ON NEXT 10;
start /home/dm8/data/usky_fire/110/111/chunk37.sql
start /home/dm8/data/usky_fire/110/66/sys_user_role_202402021054.sql
SELECT * FROM DBA_TABLES WHERE TABLESPACE_NAME = 'data_rt';
select count(*) from hce_article;
SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH, NULLABLE
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = 'sys_menu';
快速删除表中的所有数据,但保留表的结构、索引和其他相关的数据库对象:
TRUNCATE TABLE table_name;
ALTER TABLE sys_tenant DROP PRIMARY KEY;
ALTER TABLE sys_tenant MODIFY id INT IDENTITY (1045, 1);
赋予管理员权限:
GRANT SYSDBA TO usky_cloud;
查看大小写是否敏感
select PARA_VALUE from v$dm_ini where "V$DM_INI".PARA_NAME like '%CASE_SENSITIVE';
double:
decimal
重置密码:
alter user SYSDBA identified by Yt#75Usky;
查看注释:
SELECT table_name, comments FROM all_tab_comments WHERE owner = 'USKY-CLOUD' AND table_name = 'sys_check_code';
触发器:更新时间设置为实时时间
CREATE TRIGGER trg_update_time
BEFORE UPDATE ON base_company
REFERENCING NEW AS new
FOR EACH ROW
BEGIN
SET new.update_time = CURRENT_TIMESTAMP;
END;
CREATE OR REPLACE TRIGGER base_company_tmp_1
BEFORE INSERT ON base_company_tmp
FOR EACH ROW
BEGIN
IF :NEW.update_time IS NULL THEN
:NEW.update_time:= SYSDATE;
END IF;
END;
SELECT * FROM DBA_TRIGGERS;
添加索引:
CREATE INDEX build_num_index ON base_build(build_num);
统计当前目录下的文件个数(包括子目录):
bash复制代码
ls -Rl | grep "^-" | wc -l
执行shell脚本
先转换再执行:
dos2unix 777.sh
chmod +x 777.sh
#命令为脚本添加执行权限
bash usky_cloud.sh
#!/bin/bash
# 数据库连接信息
DB_HOST="localhost"
DB_PORT="5237"
DB_NAME=""
DB_USER="your_username"
DB_PASSWORD="your_password"
# SQL文件目录
SQL_DIR="/path/to/sql/files"
# 获取SQL文件列表
SQL_FILES=$(ls $SQL_DIR/*.sql)
# 登录数据库并执行SQL文件
for SQL_FILE in $SQL_FILES; do
echo "Executing SQL file: $SQL_FILE"
dmcli -h $DB_HOST -p $DB_PORT -n $DB_NAME -u $DB_USER -pw $DB_PASSWORD -s "source $SQL_FILE"
echo "SQL file executed."
done
#!/bin/bash
# 定义达梦数据库的连接信息
DB_HOST="your_host"
DB_PORT="your_port"
DB_NAME="your_database"
DB_USER="your_username"
DB_PASS="your_password"
# 定义要执行的SQL文件列表
SQL_FILES=(
"path/to/sql_file1.sql"
"path/to/sql_file2.sql"
# ... 其他SQL文件路径
)
# 循环执行SQL文件
for file in "${SQL_FILES[@]}"
do
echo "正在执行: $file"
# 使用达梦提供的命令行工具执行SQL文件
dsql -S $DB_HOST:$DB_PORT -U $DB_NAME -P $DB_USER -W -f $file
if [ $? -eq 0 ]; then
echo "执行完成: $file"
else
echo "执行失败: $file"
fi
done