<?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: Adriana Gómez</title>
    <description>The latest articles on DEV Community by Adriana Gómez (@adrigomez95).</description>
    <link>https://dev.to/adrigomez95</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%2F734482%2Fe686e7fd-7c75-48a0-8956-e5abdc809f37.jpeg</url>
      <title>DEV Community: Adriana Gómez</title>
      <link>https://dev.to/adrigomez95</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adrigomez95"/>
    <language>en</language>
    <item>
      <title>Triggers en Oracle (campos autoincrementables)</title>
      <dc:creator>Adriana Gómez</dc:creator>
      <pubDate>Tue, 30 Nov 2021 16:51:02 +0000</pubDate>
      <link>https://dev.to/adrigomez95/triggers-en-oracle-campos-autoincrementables-1gbd</link>
      <guid>https://dev.to/adrigomez95/triggers-en-oracle-campos-autoincrementables-1gbd</guid>
      <description>&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Creación de una tabla&lt;/strong&gt;
Primero, debemos tener la tabla con los campos para poder crear su trigger más adelante. Para crear la tabla, lo hacemos desde la interfaz o bien, de la siguiente manera con comandos:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CREATE TABLE Animales&lt;br&gt;
(id_animal number primary key,&lt;br&gt;
nombre VARCHAR2(25) NOT NULL,&lt;br&gt;
color VARCHAR2(25) NOT NULL);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Creación de una secuencia&lt;/strong&gt; 
Una vez la tabla esté lista, le indicamos con una secuencia, que inicie en 1 y se incremente en 1 cada vez que se vaya a insertar un dato:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CREATE SEQUENCE canimales&lt;br&gt;
START WITH 1&lt;br&gt;
INCREMENT BY 1;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Creación del trigger&lt;/strong&gt; 
Para que el campo 'id_animal' se autoincremente de una manera elegante, utilizaremos el trigger para que se encargue de obtener e insertar el valor de la secuencia automáticamente. La manera correcta de crear uno, es la siguiente:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;CREATE TRIGGER TRIG_ANIMALES&lt;br&gt;
BEFORE INSERT ON Animales&lt;br&gt;
FOR EACH ROW&lt;br&gt;
BEGIN&lt;br&gt;
SELECT canimales.NEXTVAL INTO :NEW.id_animal FROM DUAL;&lt;br&gt;
END;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hH-e37La--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvmysh6kv615ezmsaol4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hH-e37La--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvmysh6kv615ezmsaol4.png" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Este trigger lo podemos encontrar en la carpeta 'Disparadores' de las propiedades de la tabla:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rDnvcI59--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tsox5h73gljgscveocw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rDnvcI59--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8tsox5h73gljgscveocw.jpg" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inserción de datos&lt;/strong&gt; 
Listo, ahora podemos insertar datos y cada uno tendrá un id único gracias al trigger:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;INSERT INTO Animales (nombre, color)&lt;br&gt;
VALUES ('Caballo', 'Blanco');&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qud5S5qS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oemj8q2d5d54cvmhjc9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qud5S5qS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oemj8q2d5d54cvmhjc9z.png" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i_uugZz5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m61gdudg5j57jmx2cs86.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i_uugZz5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m61gdudg5j57jmx2cs86.png" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>oracle</category>
      <category>programming</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to install Oracle 18c and Docker on Ubuntu 20</title>
      <dc:creator>Adriana Gómez</dc:creator>
      <pubDate>Sat, 23 Oct 2021 20:43:53 +0000</pubDate>
      <link>https://dev.to/adrigomez95/how-to-install-oracle-18c-and-docker-on-ubuntu-20-51cj</link>
      <guid>https://dev.to/adrigomez95/how-to-install-oracle-18c-and-docker-on-ubuntu-20-51cj</guid>
      <description>&lt;h2&gt;
  
  
  First Step: installing docker on ubuntu
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Update your existing package list: 
&lt;code&gt;

$ sudo apt update 

&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Next, install some prerequisite packages that allow apt to use packages over HTTPS: 
&lt;code&gt;

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common 

&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Then, add the GPG key for the official Docker repository on your system:
&lt;code&gt;

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -  

&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add the Docker repository to the APT feeds:
&lt;code&gt;

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" 

&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Next, update the database package with the Docker packages from the newly added repository:
&lt;code&gt;

$ sudo apt update  

&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Make sure you're about to install from the Docker repository instead of the default Ubuntu repository:
&lt;code&gt;

$ apt-cache policy docker-ce  

&lt;/code&gt;
While the Docker version number may be different, you will see an output like this 
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkdbhnh6kgmh8fpy7ju0p.jpeg" alt="img2"&gt;
&lt;/li&gt;
&lt;li&gt;Finally, install Docker:
&lt;code&gt;

$ sudo apt install docker-ce 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Check that it works:
&lt;code&gt;

$ sudo systemctl status docker 

&lt;/code&gt; 
the output will show that the service is active and running :)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Second Step: installing oracle 18c on docker
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;First extract the image from the docker repository:
&lt;code&gt;

$ sudo docker pull dockerhelp/docker-oracle-ee-18c 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;We run the Oracle 18c image and assign a port where it is going to communicate:
&lt;code&gt;

$ sudo docker run -p 7000:7000 -it dockerhelp/docker-oracle-ee-18c bash 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;We run the installation file sh:
&lt;code&gt;

$ sh post_install.sh 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;We proceed to connect to the database, always inside the container:
&lt;code&gt;

$ sqlplus 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;The user who creates us by default is the following:
&lt;code&gt;

USER: sys as sysdba 

&lt;/code&gt; 
&lt;code&gt;

PASS: oracle 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;We enter and create a test user
&lt;code&gt;

SQL&amp;gt; alter session set "_ORACLE_SCRIPT"=true; 

&lt;/code&gt;
&lt;code&gt;

Session altered. 

&lt;/code&gt;
&lt;code&gt;

SQL&amp;gt; create user TEST identified by 1234; 

&lt;/code&gt;
&lt;code&gt;

User created. 

&lt;/code&gt;
&lt;code&gt;

SQL&amp;gt; grant dba to TEST; 

&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The IP of the container can be found out by exiting the container (without turning it off) with &lt;br&gt;
the key combination ctrl + p and then ctrl + q and running the following commands.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To display all containers that are active. In turn we 
will display the container id:
&lt;code&gt;

sudo docker ps 

&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;The following command is used to get the ip of the container:
&lt;code&gt;

sudo docker inspect -f '{{range 
.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [CONTAINER_ID] 

&lt;/code&gt; 
where "CONTAINER_ID" is the id generated in the previous step.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Third Step: start an existing container in docker
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The following commands are run to start the server:
&lt;code&gt;

sudo docker start aqui_tu_id_del_contenedor 

&lt;/code&gt; 
&lt;code&gt;

sudo docker exec -it aqui_tu_id_del_contenedor bash 

&lt;/code&gt; 
where "aqui_tu_id_del_contenedor" is the id of the container to start&lt;/li&gt;
&lt;li&gt;In the case of oracle 18c, the following commands are executed for sign in:
&lt;code&gt;

sh post_install.sh 

&lt;/code&gt; 
&lt;code&gt;

sqlplus 

&lt;/code&gt; 
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7dmeq1rh99vmiyxoaws0.jpg" alt="img3"&gt;
so we finish the instalation, i hope i helped you :)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>docker</category>
      <category>oracle</category>
      <category>ubuntu</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
