---
title: createGlobalTempView
description: "DataFrame.createGlobalTempView method in PySpark: Creates a global temporary view with this DataFrame."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/classes/dataframe/createGlobalTempView
---

# createGlobalTempView

Creates a global temporary view with this DataFrame.

## Syntax

```
createGlobalTempView(name: str)
```

## Parameters

| Parameter | Type | Description       |
| --------- | ---- | ----------------- |
| `name`    | str  | Name of the view. |

## Notes

The lifetime of this temporary view is tied to this Spark application. throws `TempTableAlreadyExistsException`, if the view name already exists in the catalog.

## Examples

```python
df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
df.createGlobalTempView("people")
df2 = spark.sql("SELECT * FROM global_temp.people")
df2.show()
# +---+-----+
# |age| name|
# +---+-----+
# |  2|Alice|
# |  5|  Bob|
# +---+-----+

df.createGlobalTempView("people")
# Traceback (most recent call last):
# ...
# AnalysisException: "Temporary table 'people' already exists;"

spark.catalog.dropGlobalTempView("people")
# True
```
