# Databricks notebook source
%sql
create database if not exists abcdb
%sql
use abcdb
%sql
create table student (id int , name string)
%sql
insert into student
select 1 as id, ‘user1’ as name
%sql
select * from student
spark.sql(“create database if not exists xyzdb”)
spark.sql(“use xyzdb”)
# Use three double quotes (“””) if SQL you are using has multiple lines.
spark.sql(“”” create table student1
( id int,
name string )”””)
spark.sql(“”” insert into student1
select 2 as id, ‘test1’ as name””” )
# Different format of printing or displaying dataframe.
# Selecting rows from dataframe
spark.sql(“select * from student1”).display()
spark.sql(“select * from student1”).show()
# Storing result-set in collection
spark.sql(“select * from student1”).collect
# Describe schema and datatype
spark.sql(“select * from student1”).printSchema()