top of page

Results found for ""

  • Shell Script to Check User Logins

    Shell Script to Check User Logins Linux shell script allows us to create the script to check for the login details of any user. To achieve this we will be using the last command. The last is a command-line utility that displays information about the last login sessions of the system users. vi user_login_check.sh # !/bin/bash echo "Enter the USER NAME : " read user last $user Here is the sample output of the above script More ways to use the last command. You can to print only the last ten login sessions You can also use the -p (--present) option to find out who logged into the system on a specific date. Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Check last user login

    Check last user login While performing database audits, you might need to check who logged in last into the database. The query will help you find out last user who logged in to database. select username, timestamp, action_name from dba_audit_session where action_name='LOGON' and rownum<10 and username not in ('SYS','DBSNMP','DUMMY','SYSTEM','RMAN'); Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Oracle Data Guard Startup & Shutdown Steps

    Oracle Data Guard Startup & Shutdown Steps In this article we will look at Oracle Data Guard startup and shutdown sequence. You must follow proper shutdown order to perform a graceful shutdown. Data Guard Shutdown Sequence Data Guard Startup Sequence Make sure you have permission from application owner / database architect to perform primary shutdown. Data Guard Shutdown Sequence Stop log apply service or MRP and shutdown the standby SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; SQL> SHUT IMMEDIATE; Stop log shipping from primary and shutdown primary database SQL> ALTER SYSTEM SET log_archive_dest_state_2='DEFER'; SQL> SHUT IMMEDIATE; Data Guard Startup Sequence Startup primary database and enable log shipping SQL> STARTUP; SQL> ALTER SYSTEM SET log_archive_dest_state_2='ENABLE'; Startup standby and enable log apply service or MRP SQL> startup nomount; SQL> alter database mount standby database; SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; Enjoy! Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Oracle Database Migration from Windows to Linux Using RMAN

    Oracle Database Migration from Windows to Linux Using RMAN We all know that RMAN is a powerful tool for database backup, recovery, cloning and migration. In this article, we will be perform database migration from Windows to Linux using RMAN with two scenarios. RMAN Windows to Linux Migration (same version) RMAN Windows to Linux Migration (higher version) RMAN Windows to Linux Migration (same version) In this scenario, we will be migrating Oracle database from Windows to Linux where both source and target database version are 12c. Both source & target database version is same - 12c In order to convert the database from one platform to another, the endian format of both databases should be the same. Let's check the v$transportable_platform view for both platforms col platform_name for a35 set pagesize 1000 select * from v$transportable_platform order by 2; We can see from the output that both Windows and Linux are in the little-endian format. Open the source database is read-only mode shutdown immediate; startup mount; alter database open read only; Use dbms_tdb.check_db function to check whether the database can be transported to a target platform set serveroutput on declare v_return boolean; begin v_return:=dbms_tdb.check_db('Linux x86 64-bit'); end; / If nothing is returned, then it means that the database is ready to be transported to the destination platform. Execute below function to check for the existence of external objects, directories, and BFILEs declare v_return boolean; begin v_return:=dbms_tdb.check_external; end; / Create pfile from spfile create pfile from spfile; Start RMAN conversion in SOURCE database rman target / convert database new database 'orcl' transport script 'c:\Clone\transport.sql' db_file_name_convert 'C:\app\piyus\oradata\orcl' 'c:\Clone' to platform 'Linux x86 64-bit'; Now copy the parameter file, transport.sql script, which is located at the $ORACLE_HOME/database directory, that is used to create the database and all datafiles to the destination host Create dump directories on target host cd $ORACLE_BASE mkdir -p admin/orcl/adump admin/orcl/bdump mkdir -p admin/orcl/cdump admin/orcl/udump mkdir -p oradata/orcl/ mkdir -p fast_recovery_area/orcl Copy below files carefully from source to target host: We have to copy all the datafile in oradata folder Pfile to $ORACLE_HOME/dbs and TRANSPORT.SQL to the /tmp Edit the Pfile on target host and change the path of the below: adump location control_files locations Edit the transportscript.sql file and change the locations of pdfile, redolog files and data files Now set the ORACLE_SID to orcl , connect to sqlplus and run the transport script SQL> @/tmp/TRANSPORT.SQL RMAN Windows to Linux Migration (higher version) In this scenario, we will be migrating Oracle database from Windows to Linux where both source database is 12c version and target database is 19c version. Source database is 12c and target database is 19c version In order to Clone the database from Windows 12c to Linux 19c we have to do the same as steps as we did above, we just need to edit the TRANSPORT.SQL and remove all the lines after STARTUP UPGRADE parameter Set the ORACLE_SID to orcl and run the script inside sqlplus SQL> @/tmp/TRANSPORT.SQL Our next steps is to upgrade the database to 19c cd $ORACLE_HOME/rdbms/admin $ORACLE_HOME/perl/bin/perl catctl.pl catupgrd.sql This will take around takes about 40-50mins to upgrade 12c to 19c Login to the sqlplus again and bounce the database and create spfile create SPFILE from PFILE; Run utlrp.sql script to re-compile invalid objects - if any SQL> @?/rdbms/admin/utlrp.sql Wait for the script to complete and your database migration from Windows to Linux onto a higher version is done! Further Read How to move database between platforms Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Oracle Golden Gate Bidirectional Replication

    Oracle Golden Gate Bidirectional Replication Golden gate bidirectional replication is two-way unidirectional replication . Let us set up bidirectional replication for a single table from source to target. Prerequisites Create Sample Table Setup PROD to DEV Replication Setup DEV to PROD Replication Test Bidirectional Replication Make sure supplemental logging is enabled on both source and target databases Create Sample Table Let us create a new table in fox user on the source On proddb: ========== Conn fox/fox CREATE TABLE bidir ( pname VARCHAR2(32) PRIMARY KEY, pemail VARCHAR2(64), paddr VARCHAR2(128) ); We will create the same table on target with a different name On devdb: ========= Conn tom/tom CREATE TABLE bidir_d ( pname VARCHAR2(32) PRIMARY KEY, pemail VARCHAR2(64), paddr VARCHAR2(128) ); On the source, add supplemental logging for the source table On proddb: ========== GGSCI (ggprod) 2> add trandata fox.bidir On target also, add supplemental logging for the target table On proddb: ========== GGSCI (ggprod) 2> add trandata tom.bidir_d Setup PROD to DEV Replication First, we will be configuring uni-directional replication from PROD to DEV. Add extract on proddb with below details On proddb: ========== GGSCI> ADD EXTRACT foxex, INTEGRATED TRANLOG, BEGIN NOW GGSCI> register extract foxex database  only needed in integrated capture mode GGSCI> add exttrail /u01/app/oracle/product/gg/dirdat/bi_dir/lp, extract foxex GGSCI> edit param foxex EXTRACT foxex USERID ogg, PASSWORD ogg EXTTRAIL /u01/app/oracle/product/gg/dirdat/bi_dir/lp TRANLOGOPTIONS EXCLUDEUSER OGG TABLE FOX.BIDIR; Lp -> local trail file on prod Add data pump on proddb On proddb: ========== GGSCI> Add extract foxdp, EXTTRAILSOURCE /u01/app/oracle/product/gg/dirdat/bi_dir/lp GGSCI> Add rmttrail /u01/app/oracle/product/gg/dirdat/bi_dir/rd, extract foxdp GGSCI> edit param foxdp EXTRACT foxdp USERID ogg, PASSWORD ogg RMTHOST ggdev, MGRPORT 7809 RMTTRAIL /u01/app/oracle/product/gg/dirdat/bi_dir/rd TABLE FOX.BIDIR; Add replicat on target devdb On GGDEV: ========= GGSCI> dblogin userid ogg, password ogg GGSCI> add replicat tomrep, integrated exttrail /u01/app/oracle/product/gg/dirdat/bi_ dir/rd GGSCI> edit param tomrep REPLICAT tomrep USERID ogg, PASSWORD ogg ASSUMETARGETDEFS MAP FOX.BIDIR TARGET TOM.BIDIR_D; Setup DEV to PROD Replication Now we will be configuring uni-directional replication from DEV to PROD. Add extract on devdb with below details On devdb: ========== GGSCI> ADD EXTRACT tomex, INTEGRATED TRANLOG, BEGIN NOW GGSCI> register extract tomex database  only needed in integrated capture mode GGSCI> add exttrail /u01/app/oracle/product/gg/dirdat/bi_dir/ld, extract tomex GGSCI> edit param tomex EXTRACT tomex USERID ogg, PASSWORD ogg EXTTRAIL /u01/app/oracle/product/gg/dirdat/bi_dir/ld TRANLOGOPTIONS EXCLUDEUSER OGG TABLE TOM.BIDIR_D Add data pump on devdb On devdb: ========== GGSCI> Add extract tomdp, EXTTRAILSOURCE /u01/app/oracle/product/gg/dirdat/bi_dir/ld GGSCI> Add rmttrail /u01/app/oracle/product/gg/dirdat/bi_dir/rp, extract tomdp GGSCI> edit param tomdp EXTRACT tomdp USERID ogg, PASSWORD ogg RMTHOST ggprod, MGRPORT 7809 RMTTRAIL /u01/app/oracle/product/gg/dirdat/bi_dir/rp TABLE TOM.BIDIR_D; Add replicat on target proddb On proddb: ========== GGSCI> dblogin userid ogg, password ogg GGSCI> add replicat foxrep, integrated exttrail /u01/app/oracle/product/gg/dirdat/bi_ dir/rp GGSCI> edit param foxrep REPLICAT foxrep USERID ogg, PASSWORD ogg ASSUMETARGETDEFS MAP TOM.BIDIR_D TARGET FOX.BIDIR; Test Golden Gate Bidirectional Replication Start all the extract, pump, and replicat processes on both systems and test your replication. Let us insert some rows in the table on the source On proddb: ========== INSERT INTO bidir VALUES ('Scott', 'scott@gmail.com', 'USA'); INSERT INTO bidir VALUES ('James', 'james@gmail.com', 'UK'); commit; Now try to delete the James record on devdb database, commit transactions and check on proddb if record is deleted or not. Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • ASM Related Background Process

    ASM Related Background Process Oracle ASM instance is built on same Oracle database instance architecture. Most of the ASM background processes are same as the database background process. ASM Background Process in DB Instance ASM Background Process in ASM Instance ASM Background Process in DB Instance Oracle database that uses ASM disks, two new background processes exists RBAL ASMB ASMB performs communication between the database and the ASM instance. RBAL performs the opening and closing of the disks in the disk groups on behalf of Oracle database. This RBAL is the same process as in ASM instance but it performs a different function. To find asm background process in oracle db instance, connect to Oracle database and issue below query SQL> select sid, serial#, process, name, description from v$session join v$bgprocess using(paddr); Note the ASMB and RBAL processes in the above list. You can even query using the process id at OS level (ps -ef|grep ). ASM Background Process in ASM Instance Oracle introduced two new background processes first in their 10g version: RBAL ARBn The RBAL performs rebalancing when a disk is added or removed. The ARBn performs actual extent movement between the disks in the diskgroup. To find asm background process inside asm instance, connect to ASM instance and issue below query sqlplus / as sysasm SQL> select sid, serial#, process, name, description from v$session join v$bgprocess using(paddr); Note: The ARBn process is started only when there is rebalancing operating happening inside diskgroup. Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Tablespace Point-in-time Recovery

    Tablespace Point-in-time Recovery If you already know about database point in time recovery, the issue with the database point in time recovery (DBPITR) is that the database is not accessible to users. Why Tablespace PITR Recovery? How it works? RMAN TSPITR Lab Activity CREATE TEST TABLESPACE & USER FOR ACTIVITY DROP THE TABLESPACE AND START TBPIT PROCESS CONNECT TO RMAN AND START RECOVERY Why Tablespace PITR Recovery? Let us assume that you have a problem only with one user and the transaction that the user executed has impacted one table that reside under one tablespace or one data file. So rather than performing the entire database point in time recovery, We can perform single tablespace point in time recovery just before the transactions were issued. In this way, only the affected tablespace will not be available for the users. Rest all database will still be up and running. How it works? TBPITR is different from DBPITR In DBPITR, the entire database is restored to back in time. In TBPITR, we take the tablespace back in time or before the wrong transactions are issued. It’s not straight restore and recover Once tablespace is dropped, you cannot restore at via RMAN as details of the tablespace are removed from the control file. Let us say somebody dropped the entire tablespace and then you try to issue the command restore tablespace from RMAN. The command will not work because once you drop the tablespace, control files will update that this tablespace does not exist. This means even if you try to restore it from RMAN, the tablespace will not be restored. TSPITR Recovery Methods There are three methods which you can use to recover dropped tablespace: Create DB clone with PITR before tablespace drop, export tablespace from clone DB and import into original database Perform entire database Point In Time recovery. This lead to downtime + loss of data Use automated RMAN TSPITR method RMAN TSPITR Its completely automated method. You just have to run the command TBPITR and everything will be taken care. To perform RMAN TSPITR, you need following Timestamp or SCN when tablespace was dropped → You can get this information form alert log A location with same space as your database size On the same server you need another Mount point where a database of the same size will be cloned. Once you run the TSPITR, it will Create a clone of the database in the location that you specify and then it will export the tablespace, import it into original database and then clean the cloned instance. And all the steps are automatically done by RMAN. Note: Make sure the location that you choose for the auxiliary instance of the cloned instance should have the same space or required space as an prod DB. Lab Activity In this activity, we will be doing the tablespace point in time recovery. Let us start. CREATE TEST TABLESPACE & USER FOR ACTIVITY create tablespace TBPITR datafile '/u01/app/oracle/oradata/proddb/tbpitr.dbf' size 10M; create user tbtest identified by tbtest; alter user tbtest default tablespace TBPITR; grant connect, resource to tbtest; grant select on scott.emp to tbtest; Now connect sqlplus with tbtest user and create a new emp table by selecting scott.emp table SQL> conn tbtest/tbtest SQL> create table emp as select * from scott.emp; Take RMAN backup for the activity. I am taking database backup in a specific location backup database plus archivelog format '/u02/rman_bkp/proddb/proddb_%U'; Check the database size and make sure you have a destination with same or more free space. Query to check database size col "Database Size" format a20 col "Free space" format a20 col "Used space" format a20 select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size" , round(sum(used.bytes) / 1024 / 1024 / 1024 ) - round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space" , round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space" from (select bytes from v$datafile union all select bytes from v$tempfile union all select bytes from v$log) used , (select sum(bytes) as p from dba_free_space) free group by free.p / DROP THE TABLESPACE AND START TBPIT PROCESS Now we will drop the tablespace and then we will see that we can recover it via RMAN or not. drop tablespace TBPITR including contents and datafiles; If you connect to tbtest user and query emp table, you will get below error SQL> conn tbtest/tbtest SQL> select * from emp: select * from emp * ERROR at line 1: ORA-00942: table or view does not exist Let us try to restore the tablespace using RMAN. Connect to RMAN and issue below command RMAN> restore tablespace TBPITR; ERROR: RMAN-20202: Tablespace not found in recovery catalog Reason behind the above error is that you control file is already been updated that this tablespace does not belong. Even though you have the backup, still you will not be able to restore as it is cleared from your control file. Open the alert log and check the time when the tablespace was dropped. In my activity, the timestamp is Mon Jan 16 11:01:542017 We will change this time as Mon Jan 16 11:01: 53 2017, One second before the time when the tablespace is dropped. Now we will restore this tablespace till this time. CONNECT TO RMAN AND START RECOVERY Before you fire below command, make sure you have same or more space in auxiliary destination as your original database. The auxiliary destination is the location where RMAN will automatically create the destination for the clone instance. Then export the tablespace from the cloned instance. It will put it back to the original location and then RMAN will clean this auxiliary destination also. run{ recover tablespace TBPITR until time "to_date('16-jan-17 11:01:53','dd-mon-rr hh24:mi:ss')" auxiliary destination '/u02/auxdest'; } When you fire the above command, RMAN will automatically decide one dummy instance name and start that instance. Then it will restore all the data files. It will create a database. DB will be created as per the given time which is just before the tablespace was dropped. So the tablespace will be there inside the DB. Then it will export the tablespace and put it into the production database. Once the DB clone is done. Then it will start the export of the tablespace. Once the export is done, it will start to import the tablespace into the production DB. Then it will delete the cloned files and instances. Check the original database if the tablespace restore is done or not select status,tablespace_name from dba_tablespaces; Once tablespace restore is done, it will be in offline mode. Make it online alter tablespace TBPITR online; select status,tablespace_name from dba_tablespaces; Now you can check whether you are able to query from the emp table as tbtest user. You will able to do it. Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • How to Check Oracle Instance Size

    How to Check Oracle Instance Size The first step is to understand how instance size is configured. There are two main configurations: One Instance Size Separate SGA and PGA One Instance Size Oracle MEMORY_TARGET parameter defines the total instance size. Example, If MEMORY_TARGET is set to 5 GB, oracle will manage PGA + SGA within 5 GB Show parameter memory_target; If you see memory_target value blank, then separate SGA and PGA are configured The MEMORY_MAX_TARGET parameter defines the maximum RAM that Oracle can use in case of heavy workloads. Example, if MEMORY_TARGET is set to 5 GB and MEMORY_MAX_TARGET is set to 8 GB, then during heavy workloads, Oracle instance can max take upto 8 GB RAM show parameter memory_max_target; Separate SGA and PGA Some databases require separate SGA and PGA configuration for application to work smoothly. The SGA_TARGET defines the SGA size and SGA_MAX_SIZE defines the maximum RAM SGA can take during heavy workloads. Example, if SGA_TARGET is set to 3 GB and SGA_MAX_SIZE is set to 5 GB, then during heavy workloads, SGA can max take upto 5 GB of RAM show parameter sga_target; show parameter sga_max_size; The PGA_AGGREGATE_TARGET defines the PGA size and PGA_AGGREGATE_LIMIT is set to (2 * PGA_AGGREGATE_TARGET ). Example, if PGA_AGGREGATE_TARGET is set to 4GB, then set PGA_AGGREGATE_LIMIT to 8GB (2 * PGA_AGGREGATE_TARGET ) show parameter pga_aggregate_target; show parameter pga_aggregate_limit; Hence, Instance Size= SGA_TARGET+PGA_AGGREGATE_TARGET Further Read: How to increase MEMORY_TARGET Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Echo Command in Linux

    Echo Command in Linux One of the highly used yet simple linux commands to print simple output is echo. Linux echo command allows you to print Linux environment variables , create new files, add contents to an existing file and much more. Print Linux Variable Value Print Text Containing Double Quotes Print Text Containing Single Quotes Print Text in Multiple Lines Print Special Characters Create New File or Append Print Output in Specific Colour Print Linux Variable Value To print stored value of a Linux environment variables echo $SHELL echo $HOSTNAME To print variable value with attached characters, use { } export TITLE=MR. echo "$TITLEjohn" --> No output echo "${TITLE}john" Mr.john --> output To print output of a command, enclose command in ( ) echo "Today's date is $(date)" Print Text Containing Double Quotes To print a double quote, enclose it within single quotes or use backslash echo 'This is "Linux"' or echo "This is \"Linux\"" Print Text Containing Single Quotes To print a single quote, enclose it within double quotes echo "This is 'Linux'" Print Text in Multiple Lines To print text in multiple lines, use \n character with -e option echo -e "Dear Sir \n Welcome" Print Special Characters Let's take you would like to actually print $NAME with echo command echo "Use \$NAME variable" Use $NAME variable --> output The backslash (\) will print $ as is and will not consider $NAME as a variable Create New File or Append Use > to create a new file (or overwrite existing file) echo "These are the file contents." > new_file.out Use >> to append at the end of an existing file echo "This is second line in the file." >> new_file.out Print Output in Specific Colour To print output in specific colour in Linux use below commands echo -e "\033[1;37mThis is WHITE colour" echo -e "\033[0;34mThis is BLUE colour" echo -e "\033[0;32mThis is GREEN colour" echo -e "\033[0;31mThis is RED colour" echo -e "\033[0;33mThis is YELLOW colour" echo -e "\033[1;30mThis is GRAY colour" Enjoy! 🏀🏀🏀 Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Automate RMAN Backup using Shell Script

    Automate RMAN Backup using Shell Script In a real environment, off course you will not manually trigger all the Oracle database backups. You need an automated mechanism to trigger RMAN backups. In this article, we will look at RMAN backup automation using shell scripts. Create directory structure Create RMAN backup script file Schedule Backup Under Crontab Crontab tool Create directory structure On your database server, create a directory structure to hold RMAN backups and all related files. All the RMAN backups, logs and backup scripts are kept in one directory. If you want to have a different directory structure, its complete up to your environment requirements mkdir -p /u01/rman Create RMAN backup script file Let us create the RMAN backup script file to trigger DB FULL backup vi /u01/rman/full_backup.sh #!/bin/bash . /home/oracle/.bash_profile export ORACLE_SID=proddb export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1 export DATE=$(date +%y-%m-%d_%H%M%S) rman target / log=/u01/rman/proddb_${DATE}.log << EOF run { allocate channel ch1 device type disk format '/u01/rman/proddb_full_bkp_%u'; allocate channel ch2 device type disk format '/u01/rman/proddb_full_bkp_%u'; crosscheck backup; delete noprompt obsolete; backup database; backup archivelog all delete input; release channel ch1; release channel ch2; } EOF Schedule Backup Under Crontab Give execute permissions on the shell script chmod 775 /u01/rman/full_backup.sh Now you can go ahead and schedule the backup under the crontab. For example, we are scheduling backup to trigger at 10 am and 4 pm everyday crontab -e 00 10,16 * * * /u01/rman/full_backup.sh Crontab tool Here is a crontab handy tool that I use to accurately define when crontab will execute next. Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • SQL Case Statement in Oracle

    SQL Case Statement in Oracle Oracle SQL CASE statement gives you the flexibility to use sql IF ELSE logic in a SELECT, WHERE and JOIN clause. Note: same CASE statement is used in PL/SQL blocks. Select CASE SQL For example, let us assume we need to count the number of employees whose salary is less than 2000, between 2000 & 4000 and above 4000. The below query helps counting such distinct values from a single column itself SELECT COUNT (CASE WHEN salary < 2000 THEN 1 ELSE null END) count1, COUNT (CASE WHEN salary BETWEEN 2001 AND 4000 THEN 1 ELSE null END) count2, COUNT (CASE WHEN salary > 4000 THEN 1 ELSE null END) count3 FROM employees; COUNT1 COUNT2 COUNT3 ---------- ---------- ---------- 0 43 64 With the output we can see that There are 0 employees whose salary is less than 2000 There are 43 employees whose salary is above 2000 and below 4000 There are 64 employees whose salary is grater than 4000 SQL Select CASE Example 1 For each customer in the sample customers table, the following sql query lists the credit limit as Low if it equals $100, High if it equals $5000, and Medium if it equals anything else SELECT cust_last_name, CASE credit_limit WHEN 100 THEN 'Low' WHEN 5000 THEN 'High' ELSE 'Medium' END FROM customers; CUST_LAST_NAME CASECR -------------------- ------ ... Bogart Medium Nolte Medium Loren Medium Gueney Medium SQL Select CASE Example 2 We would like to output the name of the department for the corresponding department number. For all the departments from 10 to 40 have their department name values listed, the ELSE is used to deal with any other depart number other than listed (10 to 40) SELECT ename, empno, deptno (CASE deptno WHEN 10 THEN 'Accounting' WHEN 20 THEN 'Research' WHEN 30 THEN 'Sales' WHEN 40 THEN 'Operations' ELSE 'Unknown' END) department FROM emp ORDER BY ename; SQL Select CASE Example 3 The following sql query finds the average salary of the employees in the sample table employees, using $2000 as the lowest salary possible SELECT AVG(CASE WHEN e.salary > 2000 THEN e.salary ELSE 2000 END) "Average Salary" FROM employees e; Average Salary -------------- 6461.68224 Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

  • Add ISO image storage repository on XenServer

    Add ISO image storage repository on XenServer If you have used VMware ESXI, its very easy to upload ISO files to the data store and create VMs. With Citrix XenServer, you must create your own ISO repository to upload ISO files. Create ISO directory Create repository Create ISO directory Access your XenServer via ssh and create a directory that will hold ISO images. mkdir /var/opt/ISO Use FTP client like WinSCP to copy ISO files to above directory. Create repository Now its time to register our new directory as storage repository with xenserver xe sr-create name-label=ISO_IMAGES_LOCAL type=iso device-config:location=/var/opt/ISO device-config:legacy_mode=true content-type=iso The new storage repository was created. To list your XenServer storage repository run: xe sr-list Related Posts Heading 2 Add paragraph text. Click “Edit Text” to customize this theme across your site. You can update and reuse text themes.

Search Results

bottom of page