<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ANSHUL</title>
    <description>The latest articles on DEV Community by ANSHUL (@iamanshuldev).</description>
    <link>https://dev.to/iamanshuldev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F313988%2F18821aed-9c9c-4dc5-b8e1-ebd1cb9c5e7a.jpeg</url>
      <title>DEV Community: ANSHUL</title>
      <link>https://dev.to/iamanshuldev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamanshuldev"/>
    <language>en</language>
    <item>
      <title>Synonym Of Oracle - Get Access To DB From Another Schema Easily</title>
      <dc:creator>ANSHUL</dc:creator>
      <pubDate>Wed, 13 Jul 2022 01:37:25 +0000</pubDate>
      <link>https://dev.to/iamanshuldev/synonym-of-oracle-get-access-to-db-from-another-schema-easily-14d4</link>
      <guid>https://dev.to/iamanshuldev/synonym-of-oracle-get-access-to-db-from-another-schema-easily-14d4</guid>
      <description>&lt;p&gt;A great example of a use case of synonym in Oracle PLSQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Suppose you have dedicated DB at one schema for example &lt;em&gt;stores&lt;/em&gt; and on the other hand, you have a different schema of &lt;em&gt;employees&lt;/em&gt; and some procedures are made which insert into a table from the &lt;em&gt;employees&lt;/em&gt; schema but with some reference of &lt;em&gt;store&lt;/em&gt; schema. Then we can use synonyms for accessing tables, packages, procedures, functions and more from another schema with some grants to perform specific actions like execute, insert, delete, and more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: You cannot directly access a procedure or function inside a package. Also, you have different grants for packages/procedures/functions and tables.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As I said, we have one schema &lt;em&gt;Store&lt;/em&gt; , we created a procedure &lt;em&gt;add_job_history&lt;/em&gt; to insert some records in table &lt;em&gt;job_history&lt;/em&gt; like below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create or replace NONEDITIONABLE PROCEDURE add_job_history  
  (  p_emp_id          job_history.employee_id%type  
   , p_start_date      job_history.start_date%type  
   , p_end_date        job_history.end_date%type  
   , p_job_id          job_history.job_id%type  
   , p_department_id   job_history.department_id%type   
   )  
IS  
BEGIN  
  INSERT INTO job_history (employee_id, start_date, end_date,   
                           job_id, department_id)  
    VALUES(p_emp_id, p_start_date, p_end_date, p_job_id, p_department_id);  
END add_job_history;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have to create another schema &lt;em&gt;employees&lt;/em&gt; (if you don’t have one)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create user employees identified by employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Grant to create synonym to schema &lt;em&gt;employees&lt;/em&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grant create synonym to employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: We can grant different grants to the schema as we wish according to the protocol. Please see Oracle documentation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Verify if we created a different schema using the below command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select username, account_status from dba_users;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Giving another grant to execute the procedure to schema &lt;em&gt;employees&lt;/em&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grant execute on add_job_history to employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you still face any issues with privileges, then login to &lt;strong&gt;SQLPLUS&lt;/strong&gt; with any user then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Connect sys/password as sysdba
grant execute on add_job_history to employees;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;em&gt;Employees&lt;/em&gt; schema, run the below commands:&lt;/p&gt;

&lt;p&gt;How to create a &lt;em&gt;synonym&lt;/em&gt; to access the &lt;em&gt;store&lt;/em&gt; procedure &lt;em&gt;add_job_history&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create synonym ajh_syn
for store.add_job_history;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can create a &lt;em&gt;PLSQL&lt;/em&gt; program to execute the procedure with ease.&lt;/p&gt;

&lt;p&gt;What I learned from multiple websites, I am putting everything here to make it easier for others to work. Please let me know if you have any doubts, I will try my best to give some resolution steps.&lt;/p&gt;

</description>
      <category>oracle</category>
      <category>plsql</category>
      <category>database</category>
      <category>synonym</category>
    </item>
    <item>
      <title>Personal Environment Variables</title>
      <dc:creator>ANSHUL</dc:creator>
      <pubDate>Tue, 12 Jul 2022 23:44:19 +0000</pubDate>
      <link>https://dev.to/iamanshuldev/personal-environment-variables-37ek</link>
      <guid>https://dev.to/iamanshuldev/personal-environment-variables-37ek</guid>
      <description>&lt;h3&gt;
  
  
  **
&lt;/h3&gt;

&lt;p&gt;Use&lt;br&gt;
**&lt;/p&gt;

&lt;p&gt;An environment variable is a dynamic "object" on a computer, which refers to the system checking some protocols like where to find the particular program, where to save the temporary files and many more. We set up some environment variables while installing the interpreter or compiler for any language like Java, C++, etc. Generally, it is denoted as $PATH(UNIX &amp;amp; LINUX) or PATH(Windows). The cool part of environment variables is we can make our own like any other programming variables and set some values to them. We can do some automation and some really cool stuff.&lt;/p&gt;

&lt;h3&gt;
  
  
  **
&lt;/h3&gt;

&lt;p&gt;Benefits&lt;br&gt;
**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Easy to use.&lt;/li&gt;
&lt;li&gt;    It increases efficiency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;If you are working on a project, where you are writing some python automation script and using some specific folder to create logs, save and move the modified file from one directory to another. So, you can set some environment variables for the same and use them in your script.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Make it:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export ORA=$ORA /mnt/c/Users/Admin/Oracle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will set a variable _$ORA _with the value - &lt;code&gt;/mnt/c/Users/Admin/Oracle&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to check the value:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $ORA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print the value of the $ORA which is &lt;code&gt;/mnt/c/Users/Admin/Oracle&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use it:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd $ORA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;cd is known as change directory, so the above command changes the directory to its value(your desired path) and goes to the Oracle folder.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to delete it:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export ORA=${ORA% /mnt/c/Users/Admin/Oracle}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will delete the value from the variable. I have put this command just because I messed up a big-time and I had to research out how to revert back or change the variable values.&lt;/p&gt;

&lt;p&gt;So, this is it from my end till now on this topic. If you want to add something please feel free to share. If I got some more updates then I will update the article. Thanks for reading and enjoy my write-up.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Personal Environment Variables</title>
      <dc:creator>ANSHUL</dc:creator>
      <pubDate>Tue, 28 Jun 2022 04:46:50 +0000</pubDate>
      <link>https://dev.to/iamanshuldev/personal-environment-variables-12ma</link>
      <guid>https://dev.to/iamanshuldev/personal-environment-variables-12ma</guid>
      <description>&lt;h3&gt;
  
  
  Use
&lt;/h3&gt;

&lt;p&gt;An environment variable is a dynamic "object" on a computer, which refers to the system checking some protocols like where to find the particular program, where to save the temporary files and many more. We set up some environment variables while installing the interpreter or compiler for any language like Java, C++, etc. Generally, it is denoted as $PATH(UNIX &amp;amp; LINUX) or PATH(Windows). The cool part of environment variables is we can make our own like any other programming variables and set some values to them. We can do some automation and some really cool stuff.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; Easy to use.&lt;/li&gt;
&lt;li&gt;    It increases efficiency.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;If you are working on a project, where you are writing some python automation script and using some specific folder to create logs, save and move the modified file from one directory to another. So, you can set some environment variables for the same and use them in your script.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Make it:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export ORA=$ORA /mnt/c/Users/Admin/Oracle
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will set a variable _$ORA _with the value - &lt;code&gt;/mnt/c/Users/Admin/Oracle&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to check the value:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $ORA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print the value of the $ORA which is &lt;code&gt;/mnt/c/Users/Admin/Oracle&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use it:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd $ORA
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;cd is known as change directory, so the above command changes the directory to its value(your desired path) and goes to the Oracle folder.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to delete it:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export ORA=${ORA% /mnt/c/Users/Admin/Oracle}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will delete the value from the variable. I have put this command just because I messed up a big-time and I had to research out how to revert back or change the variable values.&lt;/p&gt;

&lt;p&gt;So, this is it from my end till now on this topic. If you want to add something please feel free to share. If I got some more updates then I will update the article. Thanks for reading and enjoy my write-up.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sql Joins And How To Join?</title>
      <dc:creator>ANSHUL</dc:creator>
      <pubDate>Thu, 16 Dec 2021 04:11:37 +0000</pubDate>
      <link>https://dev.to/iamanshuldev/sql-joins-and-how-to-join-355o</link>
      <guid>https://dev.to/iamanshuldev/sql-joins-and-how-to-join-355o</guid>
      <description>&lt;p&gt;Hi, You may come here to get a tutorial on Join like different types of join and how to use it, but I wanted to tell you that I will cover that topic in future and you can find very good tutorials elsewhere.&lt;/p&gt;

&lt;p&gt;Over here I am going to illustrate different ways to join different tables. My intention for this post is to let programmers know about a few missed topics(maybe not).&lt;/p&gt;

&lt;p&gt;Let get into the topic&lt;br&gt;
There are 3 different ways to join tables:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JOIN-ON Keyword&lt;/li&gt;
&lt;li&gt;USING Keyword&lt;/li&gt;
&lt;li&gt;WHERE Keyword&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Yes, there are 3 different ways. I will go one by one with an example.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;JOIN-ON&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can join 2 tables using the Join-On keywords. It is considered as the standard way and most common way. In this case, we take two tables and place join in between them and use on later where we have to mention on which columns it is joining. This means where you can find similar records in 2 tables.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NOTE&lt;/em&gt;: you can join a table to itself. (Yes, it is possible and it is not a JOKE.)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM employees e JOIN department d ON e.department_id = d.department_id;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM employees e JOIN employees d ON e.employee_id = d.manager_id;&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;USING&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we will join tables where the column name is the same in these different tables. This is the smart A$$ and easy feature in Oracle SQL. For instance, employees table and department table both has department_id column.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example&lt;/em&gt;: &lt;br&gt;
&lt;code&gt;SELECT * FROM employees JOIN department USING department_id;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;It will print the same as from the first example from JOIN-ON.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;WHERE&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simple and Beautiful, here you can join tables using WHERE clause in which you simply mention about the columns which are equal to each other.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Examples&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM employees e JOIN department d WHERE e.department_id = d.department_id;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM employees e JOIN employees d WHERE e.employee_id = d.manager_id;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;These examples will fetch the same results as the JOIN-ON examples.&lt;/p&gt;

&lt;p&gt;Please use relevant example to practice and let me know if you find any other way.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Oracle SQL - Ways to Work on it</title>
      <dc:creator>ANSHUL</dc:creator>
      <pubDate>Mon, 01 Nov 2021 03:26:01 +0000</pubDate>
      <link>https://dev.to/iamanshuldev/oracle-sql-ways-to-work-on-it-5foc</link>
      <guid>https://dev.to/iamanshuldev/oracle-sql-ways-to-work-on-it-5foc</guid>
      <description>&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;SQL, yes and it's not MYSQL. SQL is a Structured Query Language, it is a language that is used to communicate with the database whereas MYSQL is an open-source database product(RDBMS) that allows users to keep the data organized in a database. I will write another article on this topic specifically. Let's move on.&lt;/p&gt;

&lt;p&gt;Oracle has different products and one of the famous ones other than JAVA is SQL. Some call it 'S' 'Q' 'L' and some call it 'cequel'. I am the first kind of person.&lt;/p&gt;

&lt;p&gt;When I started practicing the SQL, I discussed it with my friends/seniors and they recommended my w3schools.com. I moved to MYSQL Workbench to get some hands-on experience on it but it is slightly different from SQL.&lt;/p&gt;

&lt;p&gt;Lets Move Directly on Main Thing&lt;/p&gt;

&lt;p&gt;So after a quite research and help from the Oracle Twitter team, I explored many ways to work on it. The best part is all of them are free. They are listed below.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Online Yes, we can practice online using the Oracle Apex tool. It is an online tool where you can do almost everything possible related to SQL.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://livesql.oracle.com/apex"&gt;https://livesql.oracle.com/apex&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.Application I have mentioned that a few things that you cannot do in an online tool but do not restrict yourself and try another great application where you can become a master in SQL. So for that, you have to download the tool called Oracle Database Express Edition(XE). In order to get the latest database, you can download Database 19c or 21c from Oracle official website. Links are as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.oracle.com/ca-en/database/technologies/"&gt;https://www.oracle.com/ca-en/database/technologies/&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Virtualization Another great tool, I like the most(WHY? I will tell you in the end). First of all, I hope you have heard of another Oracle free application VirtualBox, if not then no problem. Now you read it, go search it online. It is really cool.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://www.oracle.com/database/technologies/databaseappdev-vm.html"&gt;https://www.oracle.com/database/technologies/databaseappdev-vm.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: It's taking too much space on SSD/HDD so prefer not to save on your System Drive(C Drive).&lt;/p&gt;

&lt;p&gt;Final Note I prefer Virtualization as it has many good features and safety. DataBase XE was heavy on memory and occupied a lot of space on the C drive so I had to remove it. Sad Note for MAC users, Database XE will not work for you as well as M1 chip from 2020 as has some issues with virtualization(Please try once on your system, may it works for you). For some reference, please follow this Twitter Thread&lt;br&gt;
&lt;a href="https://twitter.com/iamanshultweet/status/1445055709419290633"&gt;https://twitter.com/iamanshultweet/status/1445055709419290633&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please support the community and my Twitter account(&lt;a href="https://twitter.com/iamanshultweet"&gt;https://twitter.com/iamanshultweet&lt;/a&gt;) for another awesome article on SQL/PL-SQL.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>oracle</category>
    </item>
  </channel>
</rss>
