Oracle
 sql >> Baza danych >  >> RDS >> Oracle

Łączenie się z bazą danych Oracle 10g przez R

Poniżej znajduje się, co zrobiłem, aby połączyć R z bazą danych Oracle

  1. Pobierz sterownik Oracle JDK http://www.oracle .com/technetwork/java/javase/downloads/index.html
  2. Zainstaluj RJDBC

następnie uruchom poniższy kod w r

library(RJDBC)
## Loading required package: DBI
## Loading required package: rJava
# specify the driver type and location in your machine

jdbcDriver = JDBC("oracle.jdbc.OracleDriver",
                  classPath="C:/app/techsupport/product/11.2.0/client_1/jdbc/lib/ojdbc6.jar") # may be different on your machine, it's based on your JDK installation

# connect to the database

conn = dbConnect(jdbcDriver, "jdbc:oracle:thin:@//database.hostname.com:port/service_name",  # get the database name, port, and service name from you DBA
             user = YourUserName,
             password = YourPassword)

# get office table using a query string

startTime <- Sys.time() # start timer
OfficeTable = dbGetQuery(conn, "select * from office")
# disconnect after working with database
dbDisconnect(conn)
## [1] TRUE
Sys.time() - startTime  # calc time to import table
## Time difference of 0.1630161 secs
# take a look at the data
str(OfficeTable)
## 'data.frame':    373 obs. of  22 variables:



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Oracle BI:Wybierz wszystkie rekordy z zeszłego tygodnia

  2. Ustaw różne zmienne środowiskowe ORACLE_HOME i PATH za pomocą Ansible

  3. Jak nadać unikalne ograniczenie kombinacji kolumn w Oracle?

  4. Iteruj po wierszach drugiej tabeli, aby zwrócić zestaw wyników

  5. Globalne tabele temp — SQL Server vs Oracle