---
title: createOrReplaceGlobalTempView
description: "DataFrame.createOrReplaceGlobalTempView method in PySpark: Creates or replaces a global temporary view using the given name."
canonical_url: https://docs.databricks.com/gcp/en/pyspark/reference/classes/dataframe/createOrReplaceGlobalTempView
---

# createOrReplaceGlobalTempView

Creates or replaces a global temporary view using the given name.

## Syntax

```
createOrReplaceGlobalTempView(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.

## Examples

> [!NOTE]
>
> Databricks recommends using session-scoped temp views (`createOrReplaceTempView`) on serverless compute, since `global_temp` views are not supported. See \[createOrReplaceTempView] for the serverless-compatible alternative.

```python
df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
df.createOrReplaceGlobalTempView("people")

df2 = df.filter(df.age > 3)
df2.createOrReplaceGlobalTempView("people")
df3 = spark.table("global_temp.people")
sorted(df3.collect()) == sorted(df2.collect())
# True

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