Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment créer une base de données PostgreSQL dans AlloyDB pour PostgreSQL. Avant de pouvoir créer une base de données, vous devez créer un cluster et son instance principale.
Pour créer une base de données dans un cluster AlloyDB, connectez un client psql à l'instance principale du cluster, puis exécutez une commande PostgreSQL CREATE
DATABASE.
À l'invite de commande psql, saisissez une commande CREATE
DATABASE, comme décrit dans la documentation PostgreSQL. Exemple :
CREATEDATABASEDATABASE_NAME;
Suivez les règles PostgreSQL de la section Identifiants et mots clés lorsque vous créez votre nom de base de données.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/03 (UTC)."],[[["\u003cp\u003eThis guide outlines the process of creating a PostgreSQL database within an AlloyDB cluster.\u003c/p\u003e\n"],["\u003cp\u003eDatabase creation requires connecting a \u003ccode\u003epsql\u003c/code\u003e client to the primary instance of the AlloyDB cluster.\u003c/p\u003e\n"],["\u003cp\u003eYou need specific IAM roles, such as \u003ccode\u003eroles/alloydb.admin\u003c/code\u003e, \u003ccode\u003eroles/owner\u003c/code\u003e, or \u003ccode\u003eroles/editor\u003c/code\u003e, to perform this task.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves executing a \u003ccode\u003eCREATE DATABASE\u003c/code\u003e command at the \u003ccode\u003epsql\u003c/code\u003e prompt, adhering to PostgreSQL naming conventions.\u003c/p\u003e\n"]]],[],null,["# Create a database\n\nThis page describes how to create a PostgreSQL database in\nAlloyDB for PostgreSQL. Before you can create a database, you must [create a\ncluster and its primary instance](/alloydb/docs/cluster-create).\n\nTo create a database in an AlloyDB cluster, you connect a `psql`\nclient to the cluster's primary instance and then run a PostgreSQL `CREATE\nDATABASE` command.\n\n\nBefore you begin\n----------------\n\n- The Google Cloud project you are using must have been [enabled to access AlloyDB](/alloydb/docs/project-enable-access).\n- You must have one of these IAM roles in the Google Cloud project you are using:\n - `roles/alloydb.admin` (the AlloyDB Admin predefined IAM role)\n - `roles/owner` (the Owner basic IAM role)\n - `roles/editor` (the Editor basic IAM role)\n\n If you don't have any of these roles, contact your Organization Administrator to request\n access.\n\n\u003cbr /\u003e\n\nProcedure\n---------\n\n1. Connect a `psql` client to the cluster's primary instance, as described in [Connect a psql client to an\n instance](/alloydb/docs/connect-psql).\n2. At the `psql` command prompt, enter a `CREATE\n DATABASE` command, as described in the [PostgreSQL\n documentation](https://www.postgresql.org/docs/16/sql-createdatabase.html). For example: \n\n ```sql\n CREATE DATABASE DATABASE_NAME;\n ```\n\n Follow the PostgreSQL rules in\n [Identifiers\n and Key Words](https://www.postgresql.org/docs/16/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS) when you create your database name."]]