PyCharm 2025.2 Help

数据库图表

启用 数据库工具和 SQL 插件

此功能依赖于 数据库工具和 SQL 插件,该插件在 PyCharm 中默认捆绑并启用。 如果相关功能不可用,请确保没有禁用该插件。

  1. 按下 Ctrl+Alt+S 打开设置,然后选择 插件

  2. 打开 已安装 选项卡,找到 数据库工具和 SQL插件,然后选中插件名称旁边的复选框。

启用 Diagrams 插件

此功能依赖于 Diagrams 插件,该插件默认在 PyCharm 中捆绑并启用。 如果相关功能不可用,请确保您未禁用该插件。

  1. 按下 Ctrl+Alt+S 打开设置,然后选择 插件

  2. 打开 已安装 选项卡,找到 Diagrams插件,并勾选插件名称旁边的复选框。

数据库图表以图形方式显示数据库的结构及数据库对象之间的关系。 您可以为数据源、模式或表格生成图表。 在数据库对象之间创建关系时,请考虑使用 主键外键

您可以将生成的图表保存为两种格式:UML 和 PNG。 UML 格式是一种专门为 PyCharm 开发的内部格式。 不被其他产品支持。 如果您想共享创建的图表,请考虑使用 PNG。

此外,您可以构建执行计划。 执行计划是一组用于访问数据库中数据的步骤。 有关创建执行计划的更多信息,请参阅 可视化查询计划

为数据库对象生成一个图表

  • 数据库 工具窗口中,右键点击数据库对象并选择 图 | 显示图表.

为数据库对象生成一个图表
为数据库对象生成一个图表

查看和管理图表

平移和缩放

  • 要平移和缩放图表,请使用您的触摸板、滚动条或鼠标滚轮进行垂直滚动,以及 Shift + 鼠标滚轮进行水平滚动。 您也可以使用 Shift + 鼠标滚轮进行缩放。

  • 要使用放大工具,请按住 Alt 键并将鼠标悬停在图表的所需区域上。 使用鼠标滚轮在放大工具内进一步放大图表区域。

    放大镜工具

启用列注释

  1. 生成图表。 如需了解有关生成图表的更多信息,请参阅 为数据库对象生成一个图表

  2. 点击 注释 按钮(评论按钮)。

    启用列注释

为图表对象应用颜色

  1. 数据库 工具窗口中,右键点击对象并选择 工具 | 设置颜色…

  2. 选择一种颜色并点击 确定。 点击 刷新 按钮 () 以应用颜色并刷新图表。

    表格颜色显示

查找图表元素

要在图表中定位您的元素,请执行以下操作:

  1. Ctrl+F 以打开 图表元素 弹出窗口。

  2. 开始输入元素的名称,选择它,然后按 Enter

查找图表元素

导出图表

在 PyCharm 中,您可以将图表以各种格式导出为文件、复制到剪贴板,并在网络编辑器中打开。 您还可以打印图表并将其保存为图像。 要做到这一点,请使用图表上下文菜单中的相应操作。

在网络编辑器中打开图表

复制图表到剪贴板

  • 要将图表复制到剪贴板,请右键点击图表,导航到 导出图 | 复制到剪贴板 ,然后选择格式。

    或者,点击图表工具栏上的 导出图 按钮(导出图标 ),然后在相应的子菜单中选择格式。

    支持的格式如下:

    • Mermaid

      classDiagram direction BT class actor { varchar(45) first_name varchar(45) last_name timestamp last_update smallint unsigned actor_id } class node19 { smallint unsigned actor_id varchar(45) first_name varchar(45) last_name timestamp last_update blob column_nameimg } class actor_info { smallint unsigned actor_id varchar(45) first_name varchar(45) last_name text film_info } class address { varchar(50) address varchar(50) address2 varchar(20) district smallint unsigned city_id varchar(10) postal_code varchar(20) phone timestamp last_update smallint unsigned address_id } class category { varchar(25) name timestamp last_update tinyint unsigned category_id } class city { varchar(50) city smallint unsigned country_id timestamp last_update smallint unsigned city_id } class country { varchar(50) country timestamp last_update smallint unsigned country_id } class customer { tinyint unsigned store_id varchar(45) first_name varchar(45) last_name varchar(50) email smallint unsigned address_id tinyint(1) active datetime create_date timestamp last_update smallint unsigned customer_id } class customer_list { smallint unsigned ID varchar(91) name varchar(50) address varchar(10) zip code varchar(20) phone varchar(50) city varchar(50) country varchar(6) notes tinyint unsigned SID } class film { varchar(255) title text description year release_year tinyint unsigned language_id tinyint unsigned original_language_id tinyint unsigned rental_duration decimal(4,2) rental_rate smallint unsigned length decimal(5,2) replacement_cost enum('g', 'pg', 'pg-13', 'r', 'nc-17') rating set('trailers', 'commentaries', 'deleted scenes', 'behind the scenes') special_features timestamp last_update smallint unsigned film_id } class film_actor { timestamp last_update smallint unsigned actor_id smallint unsigned film_id } class film_category { timestamp last_update smallint unsigned film_id tinyint unsigned category_id } class film_text { varchar(255) title text description smallint film_id } class inventory { smallint unsigned film_id tinyint unsigned store_id timestamp last_update mediumint unsigned inventory_id } class language { char(20) name timestamp last_update tinyint unsigned language_id } class payment { smallint unsigned customer_id tinyint unsigned staff_id int rental_id decimal(5,2) amount datetime payment_date timestamp last_update smallint unsigned payment_id } class pet { varchar(150) pet varchar(150) name varchar(150) owner } class rental { datetime rental_date mediumint unsigned inventory_id smallint unsigned customer_id datetime return_date tinyint unsigned staff_id timestamp last_update int rental_id } class sales_by_film_category { varchar(25) category decimal(27,2) total_sales } class sales_by_store { varchar(101) store varchar(91) manager decimal(27,2) total_sales } class staff { varchar(45) first_name varchar(45) last_name smallint unsigned address_id blob picture varchar(50) email tinyint unsigned store_id tinyint(1) active varchar(16) username varchar(40) password timestamp last_update tinyint unsigned staff_id } class staff_list { tinyint unsigned ID varchar(91) name varchar(50) address varchar(10) zip code varchar(20) phone varchar(50) city varchar(50) country tinyint unsigned SID } class store { tinyint unsigned manager_staff_id smallint unsigned address_id timestamp last_update tinyint unsigned store_id } address --> city : city_id city --> country : country_id customer --> address : address_id customer --> store : store_id film --> language : original_language_id:language_id film --> language : language_id film_actor --> actor : actor_id film_actor --> film : film_id film_category --> category : category_id film_category --> film : film_id inventory --> film : film_id inventory --> store : store_id payment --> customer : customer_id payment --> rental : rental_id payment --> staff : staff_id rental --> customer : customer_id rental --> inventory : inventory_id rental --> staff : staff_id staff --> address : address_id staff --> store : store_id store --> address : address_id store --> staff : manager_staff_id:staff_id
    • PlantUML

      @startuml !theme plain top to bottom direction skinparam linetype ortho class actor { first_name: varchar(45) last_name: varchar(45) last_update: timestamp actor_id: smallint unsigned } class node16 as "actor_1 /* backup table */" { actor_id: smallint unsigned first_name: varchar(45) last_name: varchar(45) last_update: timestamp column_nameimg: blob } class actor_info { actor_id: smallint unsigned first_name: varchar(45) last_name: varchar(45) film_info: text } class address { address: varchar(50) address2: varchar(50) district: varchar(20) city_id: smallint unsigned postal_code: varchar(10) phone: varchar(20) last_update: timestamp address_id: smallint unsigned } class category { name: varchar(25) last_update: timestamp category_id: tinyint unsigned } class city { city: varchar(50) country_id: smallint unsigned last_update: timestamp city_id: smallint unsigned } class country { country: varchar(50) last_update: timestamp country_id: smallint unsigned } class customer { store_id: tinyint unsigned first_name: varchar(45) last_name: varchar(45) email: varchar(50) address_id: smallint unsigned active: tinyint(1) create_date: datetime last_update: timestamp customer_id: smallint unsigned } class customer_list { ID: smallint unsigned name: varchar(91) address: varchar(50) zip code: varchar(10) phone: varchar(20) city: varchar(50) country: varchar(50) notes: varchar(6) SID: tinyint unsigned } class film { title: varchar(255) description: text release_year: year language_id: tinyint unsigned original_language_id: tinyint unsigned rental_duration: tinyint unsigned rental_rate: decimal(4,2) length: smallint unsigned replacement_cost: decimal(5,2) rating: enum('g', 'pg', 'pg-13', 'r', 'nc-17') special_features: set('trailers', 'commentaries', 'deleted scenes', 'behind the scenes') last_update: timestamp film_id: smallint unsigned } class film_actor { last_update: timestamp actor_id: smallint unsigned film_id: smallint unsigned } class film_category { last_update: timestamp film_id: smallint unsigned category_id: tinyint unsigned } class film_text { title: varchar(255) description: text film_id: smallint } class inventory { film_id: smallint unsigned store_id: tinyint unsigned last_update: timestamp inventory_id: mediumint unsigned } class language { name: char(20) last_update: timestamp language_id: tinyint unsigned } class payment { customer_id: smallint unsigned staff_id: tinyint unsigned rental_id: int amount: decimal(5,2) payment_date: datetime last_update: timestamp payment_id: smallint unsigned } class pet { pet: varchar(150) name: varchar(150) owner: varchar(150) } class rental { rental_date: datetime inventory_id: mediumint unsigned customer_id: smallint unsigned return_date: datetime staff_id: tinyint unsigned last_update: timestamp rental_id: int } class sales_by_film_category { category: varchar(25) total_sales: decimal(27,2) } class sales_by_store { store: varchar(101) manager: varchar(91) total_sales: decimal(27,2) } class staff { first_name: varchar(45) last_name: varchar(45) address_id: smallint unsigned picture: blob email: varchar(50) store_id: tinyint unsigned active: tinyint(1) username: varchar(16) password: varchar(40) last_update: timestamp staff_id: tinyint unsigned } class staff_list { ID: tinyint unsigned name: varchar(91) address: varchar(50) zip code: varchar(10) phone: varchar(20) city: varchar(50) country: varchar(50) SID: tinyint unsigned } class store { manager_staff_id: tinyint unsigned address_id: smallint unsigned last_update: timestamp store_id: tinyint unsigned } address -[#595959,plain]-^ city : "city_id" city -[#595959,plain]-^ country : "country_id" customer -[#595959,plain]-^ address : "address_id" customer -[#595959,plain]-^ store : "store_id" film -[#595959,plain]-^ language : "language_id" film -[#595959,plain]-^ language : "original_language_id:language_id" film_actor -[#595959,plain]-^ actor : "actor_id" film_actor -[#595959,plain]-^ film : "film_id" film_category -[#595959,plain]-^ category : "category_id" film_category -[#595959,plain]-^ film : "film_id" inventory -[#595959,plain]-^ film : "film_id" inventory -[#595959,plain]-^ store : "store_id" payment -[#595959,plain]-^ customer : "customer_id" payment -[#595959,plain]-^ rental : "rental_id" payment -[#595959,plain]-^ staff : "staff_id" rental -[#595959,plain]-^ customer : "customer_id" rental -[#595959,plain]-^ inventory : "inventory_id" rental -[#595959,plain]-^ staff : "staff_id" staff -[#595959,plain]-^ address : "address_id" staff -[#595959,plain]-^ store : "store_id" store -[#595959,plain]-^ address : "address_id" store -[#595959,plain]-^ staff : "manager_staff_id:staff_id" @enduml
    • Graphviz DOT

      digraph "sakila" { splines = ortho; fontname = "Inconsolata"; node [colorscheme = ylgnbu4]; edge [colorscheme = dark28, dir = both]; actor [shape = record, label = "{ actor | first_name : varchar(45)\l last_name : varchar(45)\l last_update : timestamp\l| actor_id : smallint unsigned\l }"]; "actor_1 /* backup table */" [shape = record, label = "{ actor_1 /* backup table */ | actor_id : smallint unsigned\l first_name : varchar(45)\l last_name : varchar(45)\l last_update : timestamp\l column_nameimg : blob\l }"]; actor_info [shape = record, label = "{ actor_info | actor_id : smallint unsigned\l first_name : varchar(45)\l last_name : varchar(45)\l film_info : text\l }"]; address [shape = record, label = "{ address | address : varchar(50)\l address2 : varchar(50)\l district : varchar(20)\l city_id : smallint unsigned\l postal_code : varchar(10)\l phone : varchar(20)\l last_update : timestamp\l| address_id : smallint unsigned\l }"]; category [shape = record, label = "{ category | name : varchar(25)\l last_update : timestamp\l| category_id : tinyint unsigned\l }"]; city [shape = record, label = "{ city | city : varchar(50)\l country_id : smallint unsigned\l last_update : timestamp\l| city_id : smallint unsigned\l }"]; country [shape = record, label = "{ country | country : varchar(50)\l last_update : timestamp\l| country_id : smallint unsigned\l }"]; customer [shape = record, label = "{ customer | store_id : tinyint unsigned\l first_name : varchar(45)\l last_name : varchar(45)\l email : varchar(50)\l address_id : smallint unsigned\l active : tinyint(1)\l create_date : datetime\l last_update : timestamp\l| customer_id : smallint unsigned\l }"]; customer_list [shape = record, label = "{ customer_list | ID : smallint unsigned\l name : varchar(91)\l address : varchar(50)\l zip code : varchar(10)\l phone : varchar(20)\l city : varchar(50)\l country : varchar(50)\l notes : varchar(6)\l SID : tinyint unsigned\l }"]; film [shape = record, label = "{ film | title : varchar(255)\l description : text\l release_year : year\l language_id : tinyint unsigned\l original_language_id : tinyint unsigned\l rental_duration : tinyint unsigned\l rental_rate : decimal(4,2)\l length : smallint unsigned\l replacement_cost : decimal(5,2)\l rating : enum('g', 'pg', 'pg-13', 'r', 'nc-17')\l special_features : set('trailers', 'commentaries', 'deleted scenes', 'behind the scenes')\l last_update : timestamp\l| film_id : smallint unsigned\l }"]; film_actor [shape = record, label = "{ film_actor | last_update : timestamp\l| actor_id : smallint unsigned\l film_id : smallint unsigned\l }"]; film_category [shape = record, label = "{ film_category | last_update : timestamp\l| film_id : smallint unsigned\l category_id : tinyint unsigned\l }"]; film_text [shape = record, label = "{ film_text | title : varchar(255)\l description : text\l| film_id : smallint\l }"]; inventory [shape = record, label = "{ inventory | film_id : smallint unsigned\l store_id : tinyint unsigned\l last_update : timestamp\l| inventory_id : mediumint unsigned\l }"]; language [shape = record, label = "{ language | name : char(20)\l last_update : timestamp\l| language_id : tinyint unsigned\l }"]; payment [shape = record, label = "{ payment | customer_id : smallint unsigned\l staff_id : tinyint unsigned\l rental_id : int\l amount : decimal(5,2)\l payment_date : datetime\l last_update : timestamp\l| payment_id : smallint unsigned\l }"]; pet [shape = record, label = "{ pet | pet : varchar(150)\l name : varchar(150)\l owner : varchar(150)\l }"]; rental [shape = record, label = "{ rental | rental_date : datetime\l inventory_id : mediumint unsigned\l customer_id : smallint unsigned\l return_date : datetime\l staff_id : tinyint unsigned\l last_update : timestamp\l| rental_id : int\l }"]; sales_by_film_category [shape = record, label = "{ sales_by_film_category | category : varchar(25)\l total_sales : decimal(27,2)\l }"]; sales_by_store [shape = record, label = "{ sales_by_store | store : varchar(101)\l manager : varchar(91)\l total_sales : decimal(27,2)\l }"]; staff [shape = record, label = "{ staff | first_name : varchar(45)\l last_name : varchar(45)\l address_id : smallint unsigned\l picture : blob\l email : varchar(50)\l store_id : tinyint unsigned\l active : tinyint(1)\l username : varchar(16)\l password : varchar(40)\l last_update : timestamp\l| staff_id : tinyint unsigned\l }"]; staff_list [shape = record, label = "{ staff_list | ID : tinyint unsigned\l name : varchar(91)\l address : varchar(50)\l zip code : varchar(10)\l phone : varchar(20)\l city : varchar(50)\l country : varchar(50)\l SID : tinyint unsigned\l }"]; store [shape = record, label = "{ store | manager_staff_id : tinyint unsigned\l address_id : smallint unsigned\l last_update : timestamp\l| store_id : tinyint unsigned\l }"]; address -> city [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "city_id", headlabel = ""]; city -> country [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "country_id", headlabel = ""]; customer -> address [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "address_id", headlabel = ""]; customer -> store [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "store_id", headlabel = ""]; film -> language [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "language_id", headlabel = ""]; film -> language [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "original_language_id:language_id", headlabel = ""]; film_actor -> actor [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "actor_id", headlabel = ""]; film_actor -> film [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "film_id", headlabel = ""]; film_category -> category [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "category_id", headlabel = ""]; film_category -> film [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "film_id", headlabel = ""]; inventory -> film [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "film_id", headlabel = ""]; inventory -> store [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "store_id", headlabel = ""]; payment -> customer [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "customer_id", headlabel = ""]; payment -> rental [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "rental_id", headlabel = ""]; payment -> staff [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "staff_id", headlabel = ""]; rental -> customer [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "customer_id", headlabel = ""]; rental -> inventory [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "inventory_id", headlabel = ""]; rental -> staff [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "staff_id", headlabel = ""]; staff -> address [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "address_id", headlabel = ""]; staff -> store [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "store_id", headlabel = ""]; store -> address [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "address_id", headlabel = ""]; store -> staff [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "manager_staff_id:staff_id", headlabel = ""]; }
    • Graphviz DOT with Positions

      digraph "sakila" { splines = ortho; fontname = "Inconsolata"; node [colorscheme = ylgnbu4]; edge [colorscheme = dark28, dir = both]; actor [shape = record, pos = "4.333,20.917!" , label = "{ actor | first_name : varchar(45)\l last_name : varchar(45)\l last_update : timestamp\l| actor_id : smallint unsigned\l }"]; "actor_1 /* backup table */" [shape = record, pos = "-4.111,4.681!" , label = "{ actor_1 /* backup table */ | actor_id : smallint unsigned\l first_name : varchar(45)\l last_name : varchar(45)\l last_update : timestamp\l column_nameimg : blob\l }"]; actor_info [shape = record, pos = "-0.611,4.681!" , label = "{ actor_info | actor_id : smallint unsigned\l first_name : varchar(45)\l last_name : varchar(45)\l film_info : text\l }"]; address [shape = record, pos = "-2.564,26.375!" , label = "{ address | address : varchar(50)\l address2 : varchar(50)\l district : varchar(20)\l city_id : smallint unsigned\l postal_code : varchar(10)\l phone : varchar(20)\l last_update : timestamp\l| address_id : smallint unsigned\l }"]; category [shape = record, pos = "15.972,20.750!" , label = "{ category | name : varchar(25)\l last_update : timestamp\l| category_id : tinyint unsigned\l }"]; city [shape = record, pos = "-2.550,28.972!" , label = "{ city | city : varchar(50)\l country_id : smallint unsigned\l last_update : timestamp\l| city_id : smallint unsigned\l }"]; country [shape = record, pos = "-2.550,31.236!" , label = "{ country | country : varchar(50)\l last_update : timestamp\l| country_id : smallint unsigned\l }"]; customer [shape = record, pos = "-0.681,16.458!" , label = "{ customer | store_id : tinyint unsigned\l first_name : varchar(45)\l last_name : varchar(45)\l email : varchar(50)\l address_id : smallint unsigned\l active : tinyint(1)\l create_date : datetime\l last_update : timestamp\l| customer_id : smallint unsigned\l }"]; customer_list [shape = record, pos = "19.694,31.236!" , label = "{ customer_list | ID : smallint unsigned\l name : varchar(91)\l address : varchar(50)\l zip code : varchar(10)\l phone : varchar(20)\l city : varchar(50)\l country : varchar(50)\l notes : varchar(6)\l SID : tinyint unsigned\l }"]; film [shape = record, pos = "7.486,22.417!" , label = "{ film | title : varchar(255)\l description : text\l release_year : year\l language_id : tinyint unsigned\l original_language_id : tinyint unsigned\l rental_duration : tinyint unsigned\l rental_rate : decimal(4,2)\l length : smallint unsigned\l replacement_cost : decimal(5,2)\l rating : enum('g', 'pg', 'pg-13', 'r', 'nc-17')\l special_features : set('trailers', 'commentaries', 'deleted scenes', 'behind the scenes')\l last_update : timestamp\l| film_id : smallint unsigned\l }"]; film_actor [shape = record, pos = "9.174,15.458!" , label = "{ film_actor | last_update : timestamp\l| actor_id : smallint unsigned\l film_id : smallint unsigned\l }"]; film_category [shape = record, pos = "14.592,15.458!" , label = "{ film_category | last_update : timestamp\l| film_id : smallint unsigned\l category_id : tinyint unsigned\l }"]; film_text [shape = record, pos = "2.889,4.681!" , label = "{ film_text | title : varchar(255)\l description : text\l| film_id : smallint\l }"]; inventory [shape = record, pos = "2.889,15.625!" , label = "{ inventory | film_id : smallint unsigned\l store_id : tinyint unsigned\l last_update : timestamp\l| inventory_id : mediumint unsigned\l }"]; language [shape = record, pos = "10.731,25.542!" , label = "{ language | name : char(20)\l last_update : timestamp\l| language_id : tinyint unsigned\l }"]; payment [shape = record, pos = "-1.459,8.208!" , label = "{ payment | customer_id : smallint unsigned\l staff_id : tinyint unsigned\l rental_id : int\l amount : decimal(5,2)\l payment_date : datetime\l last_update : timestamp\l| payment_id : smallint unsigned\l }"]; pet [shape = record, pos = "9.028,4.681!" , label = "{ pet | pet : varchar(150)\l name : varchar(150)\l owner : varchar(150)\l }"]; rental [shape = record, pos = "1.321,11.833!" , label = "{ rental | rental_date : datetime\l inventory_id : mediumint unsigned\l customer_id : smallint unsigned\l return_date : datetime\l staff_id : tinyint unsigned\l last_update : timestamp\l| rental_id : int\l }"]; sales_by_film_category [shape = record, pos = "11.917,4.681!" , label = "{ sales_by_film_category | category : varchar(25)\l total_sales : decimal(27,2)\l }"]; sales_by_store [shape = record, pos = "5.583,4.681!" , label = "{ sales_by_store | store : varchar(101)\l manager : varchar(91)\l total_sales : decimal(27,2)\l }"]; staff [shape = record, pos = "-4.111,16.792!" , label = "{ staff | first_name : varchar(45)\l last_name : varchar(45)\l address_id : smallint unsigned\l picture : blob\l email : varchar(50)\l store_id : tinyint unsigned\l active : tinyint(1)\l username : varchar(16)\l password : varchar(40)\l last_update : timestamp\l| staff_id : tinyint unsigned\l }"]; staff_list [shape = record, pos = "22.666,31.236!" , label = "{ staff_list | ID : tinyint unsigned\l name : varchar(91)\l address : varchar(50)\l zip code : varchar(10)\l phone : varchar(20)\l city : varchar(50)\l country : varchar(50)\l SID : tinyint unsigned\l }"]; store [shape = record, pos = "-2.638,20.917!" , label = "{ store | manager_staff_id : tinyint unsigned\l address_id : smallint unsigned\l last_update : timestamp\l| store_id : tinyint unsigned\l }"]; address -> city [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "city_id", headlabel = ""]; city -> country [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "country_id", headlabel = ""]; customer -> address [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "address_id", headlabel = ""]; customer -> store [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "store_id", headlabel = ""]; film -> language [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "language_id", headlabel = ""]; film -> language [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "original_language_id:language_id", headlabel = ""]; film_actor -> actor [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "actor_id", headlabel = ""]; film_actor -> film [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "film_id", headlabel = ""]; film_category -> category [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "category_id", headlabel = ""]; film_category -> film [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "film_id", headlabel = ""]; inventory -> film [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "film_id", headlabel = ""]; inventory -> store [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "store_id", headlabel = ""]; payment -> customer [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "customer_id", headlabel = ""]; payment -> rental [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "rental_id", headlabel = ""]; payment -> staff [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "staff_id", headlabel = ""]; rental -> customer [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "customer_id", headlabel = ""]; rental -> inventory [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "inventory_id", headlabel = ""]; rental -> staff [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "staff_id", headlabel = ""]; staff -> address [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "address_id", headlabel = ""]; staff -> store [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "store_id", headlabel = ""]; store -> address [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "address_id", headlabel = ""]; store -> staff [color = "#595959", style = solid , arrowtail = none , arrowhead = normal , taillabel = "", label = "manager_staff_id:staff_id", headlabel = ""]; }
    通过上下文菜单将图表复制到剪贴板

将图表导出到文件

  • 要将图表导出到文件,请右键点击图表,导航到 导出图 | 导出到文件 ,然后选择格式。

    或者,点击图表工具栏上的 导出图 按钮(导出图标 ),然后在相应的子菜单中选择格式。

    支持的格式如下:

    • YEd .graphml

    • JGraph .drawio

    • Graphviz .dot

    • Graphviz .dot 带位置

    • 美人鱼 .md

    • PlantUML

    • IDEA .uml :UML 格式是 PyCharm 独家支持的内部格式。 要打开已保存的图表,请将 UML 文件拖到编辑器。

      请注意,UML 文件的范围仅限于原始项目。 它只能在创建它的同一项目中打开和使用。

    通过上下文菜单导出图表到文件

将图表导出为 PNG 格式的图片

  • 要将您的图表导出为 PNG 格式的图像,请右键点击图表并选择 导出图 | 导出到图像…

    或者,点击图表工具栏中的 导出图 按钮(导出图标 ),然后选择 导出到图像…

参考

图标

图表中列的可能图标组合:

图标

外键

主键

已建立索引

NOT NULL

列

带有外键的列

具有外键

带有主键的列

有主键

索引列

索引

不接受 NULL 值的列

具有NOT NULL约束

不接受 NULL 值的索引列

已建立索引

具有NOT NULL约束

带有主键和外键且不接受 NULL 值的索引列

具有外键

具有主键

已建立索引

具有NOT NULL约束

带有主键和外键的索引列

具有外键

具有主键

已建立索引

不接受 NULL 值的含有主键和外键的列

具有外键

具有主键

具有NOT NULL约束

包含主键和外键的列

具有外键

具有主键

不接受 NULL 值的带有外键的索引列

有一个外键

已建立索引

具有NOT NULL约束

不接受 NULL 值的外键列

有一个外键

具有NOT NULL约束

带有外键且接受 NULL 值的索引列

有一个外键

已建立索引

带有主键且不接受 NULL 值的索引列

有主键

索引

具有 NOT NULL 约束

不接受 NULL 值的主键列

具有主键

具有NOT NULL约束

带主键的索引列

有主键

索引

图表配置设置

要配置图表的默认可见性设置和布局,请按 Ctrl+Alt+S 打开设置,然后导航到 工具 | 图表。 。

如需了解有关数据库图配置设置的更多信息,请参阅 图表 参考主题。

“Diagrams”菜单

工具栏和上下文菜单

使用图表编辑器工具栏快速访问操作,并使用上下文菜单管理显示的图表。

工具栏

项目

描述

"“关键列”按钮"

(适用于数据库操作时。)点击此按钮以在图表中显示主键列。

“Columns 按钮”

(当您使用数据库时可用。)切换显示下列内容:

  • 对于数据库对象的可视化:在图表中显示或隐藏主键列以外的其他列。

  • 对于查询映射:显示或隐藏查询属性。 这些属性可以是行数、索引名称或有关查询的任何其他附加信息。

虚拟外键按钮

(适用于数据库操作时。)点击此按钮以在图表中隐藏或显示虚拟外键。

评论按钮

(适用于数据库操作时。)点击此按钮以在图表中隐藏或显示注释。

放大

点击此图标以增加图表的比例。 或者按 NumPad+

缩小

点击此图标以减少图表的比例。 或者按 NumPad-

实际大小

点击此图标可恢复图表的实际大小。

适应内容

点击此图标以使内容适应当前图表大小。

应用当前布局

点击此图标以应用从图表上下文菜单的 布局 节点中选择的当前布局。

路由装订区域

点击此图标以将图表缩放到窗口装订区域。

将图表复制到剪贴板

点击此图标以将图表复制到剪贴板。

将选定内容复制到剪贴板

点击此图标,然后用鼠标选择任意图表区域:所选区域将被复制到剪贴板。

保存图片

点击此图标以将当前图表导出为 PNG 格式。

打印

点击此图标以打印图表。

上下文菜单

下表包含工具栏中不可用的命令。

项目

描述

选定元素操作

使用此选项打开应用于图中选定元素的操作列表。 您可以选择操作以复制元素、跳转到其源代码、查找其用法、使用 导航 操作、各种 Git 操作等。

内容

使用此选项可打开操作列表,这些操作可帮助您添加新元素、显示依赖关系、对图中的元素进行排序,等等。

  • 新建Alt+Insert):

    选择此命令以创建新节点元素或成员。

  • 显示类别 :选择此命令以在类节点中显示选定的代码元素。 例如,您可以选择 字段 以查看类中的所有 field 元素。

删除

删除所选的图表。

分析图表

使用此节点选择其中一个命令以分析图表。 您可以检查图表特性、改变图表焦点、测量图表中心性等。

布局

从子菜单中选择所需的图表布局。

方向

为您提供以下定向选项:Bottom to Top、Top to Bottom 等等。

应用当前布局

将当前布局应用于从图表上下文菜单的 布局 节点中选择的布局

路由装订区域

将图表内容缩放至图表窗口的装订区域。

外观

通过显示网格、装订区域标签、桥来管理图表的呈现方式。 允许您合并装订区域并选择装订区域形状。

行为

使用此选项选择与图表行为相关的命令,如对齐元素到网格、显示所选节点的结构视图或在布局后适应内容。

导出图表

您可以选择并配置以下选项:

  • 将图表复制到剪贴板将图表复制到剪贴板 :点击此图标将图表复制到剪贴板。

  • 将选定内容复制到剪贴板将选定内容复制到剪贴板 :点击此图标,然后使用鼠标选择任何图表区域:选定的区域将被复制到剪贴板。

  • 导出为图像导出到图像… :单击此选项以将图表保存为图像。

  • 打印打印(P)… :单击此选项以打印图表。

最后修改日期: 2025年 9月 26日