How to create a table in SQL Server?
To create a table in SQL Server, you need to use the CREATE TABLE statement. Here is an example:
CREATE TABLE 表名 (
列名1 数据类型,
列名2 数据类型,
列名3 数据类型,
...
);
In the code above, you need to replace “table name” with the name of the table you want to create and list the columns and data types in parentheses. After each column name, you need to specify the data type of that column.
For example, here is an example of creating a table named “Customers” that includes columns for id, name, and email.
CREATE TABLE Customers (
id INT,
name VARCHAR(50),
email VARCHAR(100)
);
In the example above, the data type for the id column is INT (integer), while the data types for the name and email columns are VARCHAR with maximum lengths of 50 and 100, respectively.
Please remember that when actually in use, you can also specify additional attributes for the columns of the table, such as primary key, foreign key, default values, etc.