本站用于记录日常工作内容,虚拟化云计算,系统运维,数据库DBA,网络与安全。
PostgreSQL新手入门作者: 阮一峰日期: 2013年12月22日自从MySQL被Oracle收购以后,PostgreSQL逐渐成为开源关系型数据库的首选。本文介绍PostgreSQL的安装和基本用法,供初次使用者上手。以下内容基于Debian操作系统,其他操作系统实在没有精力兼顾,但是大部分内容应该普遍适用。一、安装首先,安装PostgreSQL客户端。sudo apt-get install postgresql-client然后,安装PostgreSQL服务器。sudo apt-get install postgresql正常情况下,安装完成后,PostgreSQL服务器会自动在本机的5432端口开启。如果还想安装图形管理界面,可以运行下面命令,但是本文不涉及这方面内容。sudo apt-get install pgadmin3二、添加新用户和新数据库初次安装后,默认生成一个名为postgres的数据库和一个名为postgres的数据库用户。这里需要注意的是,同时还生成了一个名为postgres的Linux系统用户。下面,我们使用postgres用户,来生成其他用户和新数据库。好几种方法可以达到这个目的,这里介绍两种。第一种方法,使用PostgreSQL控制台。首先,新建一个Linux新用户,可以取你想要的名字,这里为dbuser。sudo adduser dbuser然后,切换到postgres用户。sudo su - postgres下一步,使用...
Oracle 创建视图与 使用函数转换时间戳方法。CREATE OR REPLACE FORCE VIEW VIEW_SIM( SIM, BILL_NUM, EQUIP_TYPE, POSITION_TYPE, SIGN_STATE, GOLD_STATE, OPERATE_ID, STARTTIME, UPDATETIME)AS SELECT t.sim, t.bill_num, t.equip_type, t.position_type, t.sign_state, t.gold_state, t.operate_id, fun_utc2date (UTCDATE => t.starttime, PATTERN => 'YYYY-MM-DD HH24:MI:SS') AS starttime, fun_utc2date (UTCDATE => t.updatetime, &n...
Oracle 利用函数将时间戳转换成日期格式的方法。数据库中有三个字段,其中关于 时间的是采用 时间戳的格式存储的,如下图 SIM BILL_NUM STARTTIME 18307135480 9001445665 1598016414 18707204757 9001445665 1598016417 15207169407 9003664475 1598251705 18827672101 9003664475 1598251707 13437294319 99270014770 1598343236 13554194307 99270014770 1598343237 13437294316 99270014770 1598343238 13554194616 99270014770 1598343238 如果要查询一段时间内的数据,每次都要转换时间格式,很不方面。但是可以作了 时间戳转换日期的函数,这样每次只需要调用就可以了。/* 格式化对象 2020/9/2 16:47:52 (QP5 v5.287) */CREATE OR REPLACE FUNCTION FUN_UTC2DATE (UTCDATE NUMBER, PATTERN VARCHAR2) RETURN DATEIS Result DATE;BEGIN Result := TO_DATE ( TO_CHAR ( TO_DATE (19700101000000, 'YYYYMMDDHH24MISS') &n...
oracle PLSQL,游标,loop循环删除部分表方法。使用Toad for Oracle时,使用新建用户连接时,连接身份 搞成了 as sysdba,导致执行添加表与表数据时,都变成sys账号下了。表比较多,删除时使用游标与loop循环,执行不成功。不清楚哪里不对(主要是水平太次,)。如下:declare CURSOR d_cursor is SELECT OBJECT_NAME FROM sys.DBA_objects WHERE OBJECT_TYPE = 'TABLE' AND owner = 'STUDENT'; d_record d_cursor%ROWTYPE;begin OPEN d_cursor; LOOP FETCH d_cursor INTO d_record; EXIT WHEN d_cursor%NOTFOUND; execute immediate 'DROP TABLE ' || d_record.object_name || ' cascade constraints'; Dbms_Output.put_line(d_record.object_name || ' 表删除成功'); end loop; close d_cursor; commit;end;/行 2 出错ORA-00942: 表或视图不存在ORA-06512: 在 line 19脚本已在第 2行终止。(搞了很久才清楚,在sys或system账号会话连接中,只要添加 execute im...
下载备份脚本文件windows: 下载http://downinfo.myhostadmin.net/vps/bkupmysql.bat 保存到d盘根目录linux: wget http://downinfo.myhostadmin.net/vps/bkupmysql.sh 保存到/root目录3.编辑脚本文件windows:用记事本打开bkupmysql.bat set dbuser=root #设置数据库用户,一般不需要修改set dbpass=passwd #设置数据库超管密码,需要修改为实际的密码set DaysAgo=7 #设置保留天数set mysqlpath=d:\mysqlbak #设置备份文件保存路径,一般不需要修改set mysql=D:\SOFT_PHP_PACKAGE\mysql\bin\mysql.exe #设置备份文件保存路径,5.6版本需要修改路径set mysqldump=D:\SOFT_PHP_PACKAGE\mysql\bin\mysqldump.exe #设置mysql执行文件路径,5.6版本需要修改路径set logfile=d:\bkinfo.log &n...
Redis 安全我们可以通过 redis 的配置文件设置密码参数,这样客户端连接到 redis 服务就需要密码验证,这样可以让你的 redis 服务更安全。实例我们可以通过以下命令查看是否设置了密码验证:127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) ""默认情况下 requirepass 参数是空的,这就意味着你无需通过密码验证就可以连接到 redis 服务。你可以通过以下命令来修改该参数:127.0.0.1:6379> CONFIG set requirepass "runoob"
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "runoob"设置密码后,客户端连接 redis 服务就需要密码验证,否则无法执行命令。语法AUTH 命令基本语法格式如下:127.0.0.1:6379> AUTH password实例127.0.0.1:6379> AUTH "runoob"
OK
127.0.0.1:6379> SET mykey "Test value"
OK
127.0.0.1:6379> GET mykey
"Test value"
Redis 数据备份与恢复Redis SAVE 命令用于创建当前数据库的备份。语法redis Save 命令基本语法如下:redis 127.0.0.1:6379> SAVE 实例redis 127.0.0.1:6379> SAVE
OK该命令将在 redis 安装目录中创建dump.rdb文件。恢复数据如果需要恢复数据,只需将备份文件 (dump.rdb) 移动到 redis 安装目录并启动服务即可。获取 redis 目录可以使用 CONFIG 命令,如下所示:
redis 127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/usr/local/redis/bin"
以上命令 CONFIG GET dir 输出的 redis 安装目录为 /usr/local/redis/bin。Bgsave创建 redis 备份文件也可以使用命令 BGSAVE,该命令在后台执行。实例127.0.0.1:6379> BGSAVE
Background saving started
How To Shrink A Temporary Tablespace in Oracle DatabaseBy adminQuestion: How to resize the TEMPFILE(s) for a temporary tablespace after they have grown larger than needed?Large sort operations can cause temporary tablespaces to grow very large and as such there may be a need to ‘downsize’ after such operations. Until Oracle 11g there was no SQL command to release the unused allocated temporary space. One workaround for this problem is to create a new empty temporary tablespace with a smaller size, assign this new tablespace to the users and then drop the old tablespace. The disadvantage of this procedure is that it requires that no active sort operations are happening within the old temporary tablespace while it is being dropped.In Oracle 11g, a new feature was added that can be used to shrink temporary tablespaces. This command can be used to shrink only locally managed temporary tablespaces :ALTER TABLESPACE tablespace SHRINK SPACE | TEMPFILE tempfile_name [KEEP size];The&nbs...
What is MySQL Query CacheMySQL server features Query Cache Feature for a long time. When in use, the query cache stores the text of a SELECT query together with the corresponding result that is sent to a client. If another identical query is received, the server can then retrieve the results from the query cache rather than parsing and executing the same query again.It caches the full result set produced from a SELECT query:Queries executed must be identical.Cache is stored in system memory.Cache is checked before the query is parsed.Associated table updates invalidate query cache results. Prepared statements can be cached, but limitations exist. Some statements that do not use the query cache are:Queries that use nondeterministic functions.Queries that are a subquery of an outer queryQueries that are executed within the body of a stored function, trigger, or eventMySQL Query Cache SettingsThe query cache adds a few MySQL system variables for mysqld which may be set in a configuration...
Windows下Oracle因主机名或IP变动,导致EM无法启动的问题。错误信息:WIN的事件查看器:An error occured while trying to initialize the service.手工启动:emctl start dbconsoleEnvironment variable ORACLE_SID not defined. Please define it.当执行set OARCLE_SID=orcl,继续报错Unable to determine local host from URL REPOSITORY_URL= http://localhost:%EM_UPLOAD_PORT%/em/upload/注意以下地方:1: 主机名:C:/WINDOWS/system32/drivers/etc/hosts添加IP与主机名信息。Windows系统中打开 数据库配置助手,配置数据库选件,根据提示配置账号与密码,会重新生成dbcosole相关数据。完成后,最好重启下系统,看下自己的监听配置。2: EM链接JDBC:$ORACLE_HOME/oc4j/j2eeOC4J_DBConsole_fox-kook_kookOC4J_DBConsole_localhost_kook (从fox-kook主机名复制这个目录为localhost)3: 监听修改为主机名的连接方式,不要以IP方式。$ORACLE_HOME/NETWORK/ADMIN/listener.oraSID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = kook.glfsoft.com)  ...
总共51页,当前第10页 | 页数: - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
最新评论