Learn R Programming

dlookr (version 0.3.9)

get_column_info: Describe column of table in the DBMS

Description

The get_column_info() retrieves the column information of the DBMS table through the tbl_bdi object of dplyr.

Usage

get_column_info(df)

Arguments

df

a tbl_dbi.

Value

An object of data.frame.

Column information of the DBMS table

  • SQLite DBMS connected RSQLite::SQLite():

    • name: column name

    • type: data type in R

  • MySQL/MariaDB DBMS connected RMySQL::MySQL():

    • name: column name

    • Sclass: data type in R

    • type: data type of column in the DBMS

    • length: data length in the DBMS

  • Oracle DBMS connected ROracle::dbConnect():

    • name: column name

    • Sclass: column type in R

    • type: data type of column in the DBMS

    • len: length of column(CHAR/VARCHAR/VARCHAR2 data type) in the DBMS

    • precision: precision of column(NUMBER data type) in the DBMS

    • scale: decimal places of column(NUMBER data type) in the DBMS

    • nullOK: nullability

Examples

Run this code
# NOT RUN {
library(dplyr)

# Generate data for the example
carseats <- ISLR::Carseats
carseats[sample(seq(NROW(carseats)), 20), "Income"] <- NA
carseats[sample(seq(NROW(carseats)), 5), "Urban"] <- NA

# connect DBMS
con_sqlite <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")

# copy carseats to the DBMS with a table named TB_CARSEATS
copy_to(con_sqlite, carseats, name = "TB_CARSEATS", overwrite = TRUE)

con_sqlite %>% 
  tbl("TB_CARSEATS") %>% 
  get_column_info
# }

Run the code above in your browser using DataLab