How can you create a new table in Snowflake? Provide an example SQL statement.

0

How can you create a new table in Snowflake? Provide an example SQL statement.

Daniel Steinhold Answered question August 6, 2023
0

To create a new table in Snowflake, you can use the CREATE TABLE statement. Here's an example SQL statement that demonstrates how to create a simple table:

```sql
sqlCopy code
CREATE TABLE Employee (
EmployeeID INT,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(100),
Salary DECIMAL(10, 2)
);

```

In this example:

- **`CREATE TABLE`** is the SQL command used to create a new table.
- **`Employee`** is the name of the table being created.
- **`(EmployeeID INT, FirstName VARCHAR(50), LastName VARCHAR(50), Department VARCHAR(100), Salary DECIMAL(10, 2))`** specifies the columns of the table along with their data types and optional constraints.

Here's a breakdown of the columns:

- **`EmployeeID`**: An integer column that will store employee IDs.
- **`FirstName`**: A variable character (string) column that will store employee first names.
- **`LastName`**: A variable character (string) column that will store employee last names.
- **`Department`**: A variable character (string) column that will store the department name.
- **`Salary`**: A decimal column with precision 10 and scale 2, used to store employee salaries.

You can customize the table's structure by adding or modifying columns, data types, constraints, and other options according to your specific requirements.

Daniel Steinhold Answered question August 6, 2023

Maximize Your Data Potential With ITS

Feedback on Q&A