---
title: "CREATE SERVER"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_create_server/"
---

# CREATE SERVER

Use the CREATE SERVER statement to create a foreign server.

## Synopsis

Use the `CREATE SERVER` command to create a foreign table.

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
create_server ::= CREATE SERVER [ IF NOT EXISTS ] server_name  
                  [ TYPE server_type ] [ VERSION server_version ]  
                  FOREIGN DATA WRAPPER fdw_name 
                  [ OPTIONS ( fdw_options ) ]
```

#### create\_server

CREATESERVERIFNOTEXISTS[server\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#server-name)TYPE[server\_type](/stable/api/ysql/syntax_resources/grammar_diagrams#server-type)VERSION[server\_version](/stable/api/ysql/syntax_resources/grammar_diagrams#server-version)FOREIGNDATAWRAPPER[fdw\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#fdw-name)OPTIONS([fdw\_options](/stable/api/ysql/syntax_resources/grammar_diagrams#fdw-options))

## Semantics

Create a foreign server named *server\_name*. If *server\_name* already exists in the specified database, an error will be raised unless the `IF NOT EXISTS` clause is used.

### Type

The `TYPE` clause can be optionally used to specify the server type.

### Server Version

The `VERSION` clause can be optionally used to specify the server version.

### FDW name

The `FOREIGN DATA WRAPPER` clause can be used to specify the name of the foreign-data wrapper.

### Options:

The `OPTIONS` clause specifies options for the foreign server. They typically define the connection details of the server, but the actual permitted option names and values are specific to the server’s foreign data wrapper.

## Examples

Basic example.

```plpgsql
yugabyte=#  CREATE SERVER my_server FOREIGN DATA WRAPPER my_wrapper OPTIONS (host '187.51.62.1');
```

## See also

- [CREATE FOREIGN DATA WRAPPER](/stable/api/ysql/the-sql-language/statements/ddl_create_foreign_data_wrapper/ "CREATE FOREIGN DATA WRAPPER")
- [CREATE FOREIGN TABLE](/stable/api/ysql/the-sql-language/statements/ddl_create_foreign_table/ "CREATE FOREIGN TABLE")
- [CREATE USER MAPPING](/stable/api/ysql/the-sql-language/statements/ddl_create_user_mapping/ "CREATE USER MAPPING")
- [IMPORT FOREIGN SCHEMA](/stable/api/ysql/the-sql-language/statements/ddl_import_foreign_schema/ "IMPORT FOREIGN SCHEMA")
- [ALTER SERVER](/stable/api/ysql/the-sql-language/statements/ddl_alter_server/ "ALTER SERVER")
