获取 PostgreSQL 某个表的定义

news/2024/4/27 16:04:10/文章来源:https://blog.csdn.net/liufeng1980423/article/details/137067211

PostgreSQL自己带了获取各种对象定义的函数,如下所示:

test=# \df *get*def*函数列表架构模式  |              名称              | 结果数据类型 |     参数数据类型      | 类型
------------+--------------------------------+--------------+-----------------------+------pg_catalog | pg_get_constraintdef           | text         | oid                   | 函数pg_catalog | pg_get_constraintdef           | text         | oid, boolean          | 函数pg_catalog | pg_get_function_arg_default    | text         | oid, integer          | 函数pg_catalog | pg_get_functiondef             | text         | oid                   | 函数pg_catalog | pg_get_indexdef                | text         | oid                   | 函数pg_catalog | pg_get_indexdef                | text         | oid, integer, boolean | 函数pg_catalog | pg_get_partition_constraintdef | text         | oid                   | 函数pg_catalog | pg_get_partkeydef              | text         | oid                   | 函数pg_catalog | pg_get_ruledef                 | text         | oid                   | 函数pg_catalog | pg_get_ruledef                 | text         | oid, boolean          | 函数pg_catalog | pg_get_statisticsobjdef        | text         | oid                   | 函数pg_catalog | pg_get_triggerdef              | text         | oid                   | 函数pg_catalog | pg_get_triggerdef              | text         | oid, boolean          | 函数pg_catalog | pg_get_viewdef                 | text         | oid                   | 函数pg_catalog | pg_get_viewdef                 | text         | oid, boolean          | 函数pg_catalog | pg_get_viewdef                 | text         | oid, integer          | 函数pg_catalog | pg_get_viewdef                 | text         | text                  | 函数pg_catalog | pg_get_viewdef                 | text         | text, boolean         | 函数
(18 行记录)

但是并没有查询表定义的函数,但是查询表是经常被使用到的,像openguassdb已经都加上了,在网上找了下别人定义的,修改了下,如下:

-- Change History:
-- 2022-09-19  MJV FIX: Do not add CREATE INDEX statements if they indexes are defined within the Table definition as ADD CONSTRAINT.
do $$ 
<<first_block>>
DECLAREcnt int;
BEGINSELECT count(*) into cntFROM pg_catalog.pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)AND n.nspname <> 'pg_catalog' AND n.nspname <> 'information_schema' AND pg_catalog.pg_type_is_visible(t.oid)AND pg_catalog.format_type(t.oid, NULL) in ('tabledef_fkeys','tabledef_trigs');IF cnt = 0 THENRAISE INFO 'Creating custom types.';CREATE TYPE public.tabledef_fkeys AS ENUM ('FKEYS_INTERNAL', 'FKEYS_EXTERNAL', 'FKEYS_COMMENTED', 'FKEYS_NONE');CREATE TYPE public.tabledef_trigs AS ENUM ('INCLUDE_TRIGGERS', 'NO_TRIGGERS');END IF;
end first_block $$;-- SELECT count(*) into cnt
-- FROM pg_catalog.pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) 
-- AND NOT EXISTS(SELECT 1 FROM pg_catalog.pg_type el WHERE el.oid = t.typelem AND el.typarray = t.oid)
-- AND n.nspname <> 'pg_catalog' AND n.nspname <> 'information_schema' AND pg_catalog.pg_type_is_visible(t.oid)
-- AND pg_catalog.format_type(t.oid, NULL) in ('tabledef_fkeys','tabledef_trigs');-- Create enum types used by this function
-- DROP TYPE IF EXISTS public.tabledef_fkeys;
-- DROP TYPE IF EXISTS public.tabledef_trigs;
-- CREATE TYPE public.tabledef_fkeys AS ENUM ('FKEYS_INTERNAL', 'FKEYS_EXTERNAL', 'FKEYS_COMMENTED', 'FKEYS_NONE');
-- CREATE TYPE public.tabledef_trigs AS ENUM ('INCLUDE_TRIGGERS', 'NO_TRIGGERS');-- SELECT * FROM public.pg_get_tabledef('sample', 'address');
CREATE OR REPLACE FUNCTION public.pg_get_tabledef(in_schema varchar,in_table varchar,in_fktype  public.tabledef_fkeys DEFAULT 'FKEYS_INTERNAL',in_trigger public.tabledef_trigs DEFAULT 'NO_TRIGGERS'
)
RETURNS text
LANGUAGE plpgsql VOLATILE
AS
$$/* ********************************************************************************
COPYRIGHT NOTICE FOLLOWS.  DO NOT REMOVE
Copyright (c) 2021 SQLEXEC LLCPermission to use, copy, modify, and distribute this software and its documentation 
for any purpose, without fee, and without a written agreement is hereby granted, 
provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.IN NO EVENT SHALL SQLEXEC LLC BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,INDIRECT SPECIAL, 
INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE 
OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF SQLEXEC LLC HAS BEEN ADVISED OF THE 
POSSIBILITY OF SUCH DAMAGE.SQLEXEC LLC SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 
THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND SQLEXEC LLC HAS 
NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.************************************************************************************ */-- History:
-- Date	     Description
-- ==========   ======================================================================  
-- 2021-03-20   Original coding using some snippets from 
--              https://stackoverflow.com/questions/2593803/how-to-generate-the-create-table-sql-statement-for-an-existing-table-in-postgr
-- 2021-03-21   Added partitioned table support, i.e., PARTITION BY clause.
-- 2021-03-21   Added WITH clause logic where storage parameters for tables are set.
-- 2021-03-22   Added tablespace logic for tables and indexes.
-- 2021-03-24   Added inheritance-based partitioning support for PG 9.6 and lower.
-- 2022-09-12   Fixed Issue#1: Added fix for PostGIS columns where we do not presume the schema, leave without schema to imply public schemaDECLAREv_table_ddl text;v_table_oid int;v_colrec record;v_constraintrec record;v_indexrec record;v_primary boolean := False;v_constraint_name text;v_fkey_defs text;v_trigger text := '';v_partition_key text := '';v_partbound text;v_parent text;v_persist text;v_temp  text := ''; v_relopts text;v_tablespace text;v_pgversion int;bPartition boolean;bInheritance boolean;bRelispartition boolean;constraintarr text[] := '{}';constraintelement text;bSkip boolean;BEGINSELECT c.oid, (select setting from pg_settings where name = 'server_version_num') INTO v_table_oid, v_pgversion FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespaceWHERE c.relkind in ('r','p') AND c.relname = in_table AND n.nspname = in_schema;-- RAISE NOTICE 'version=%', v_pgversion;-- throw an error if table was not foundIF (v_table_oid IS NULL) THENRAISE EXCEPTION 'table does not exist';END IF;-- get user-defined tablespaces if applicableSELECT tablespace INTO v_temp FROM pg_tables WHERE schemaname = in_schema and tablename = in_table and tablespace IS NOT NULL;IF v_tablespace IS NULL THENv_tablespace := 'TABLESPACE pg_default';ELSEv_tablespace := 'TABLESPACE ' || v_temp;END IF;-- also see if there are any SET commands for this table, ie, autovacuum_enabled=off, fillfactor=70WITH relopts AS (SELECT unnest(c.reloptions) relopts FROM pg_class c, pg_namespace n WHERE n.nspname = in_schema and n.oid = c.relnamespace and c.relname = in_table) SELECT string_agg(r.relopts, ', ') as relopts INTO v_temp from relopts r;IF v_temp IS NULL THENv_relopts := '';ELSEv_relopts := ' WITH (' || v_temp || ')';END IF;-- ------------------------------------------------------------------------------------- Create table defs for partitions/children using inheritance or declarative methods.-- inheritance: pg_class.relkind = 'r'   pg_class.relispartition=false   pg_class.relpartbound is NULL-- declarative: pg_class.relkind = 'r'   pg_class.relispartition=true    pg_class.relpartbound is NOT NULL-- -----------------------------------------------------------------------------------v_partbound := '';bPartition := False;bInheritance := False;IF v_pgversion < 100000 THENSELECT c2.relname parent INTO v_parent from pg_class c1, pg_namespace n, pg_inherits i, pg_class c2WHERE n.nspname = in_schema and n.oid = c1.relnamespace and c1.relname = in_table and c1.oid = i.inhrelid and i.inhparent = c2.oid and c1.relkind = 'r';      IF (v_parent IS NOT NULL) THENbPartition   := True;bInheritance := True;END IF;ELSESELECT c2.relname parent, c1.relispartition, pg_get_expr(c1.relpartbound, c1.oid, true) INTO v_parent, bRelispartition, v_partbound from pg_class c1, pg_namespace n, pg_inherits i, pg_class c2WHERE n.nspname = in_schema and n.oid = c1.relnamespace and c1.relname = in_table and c1.oid = i.inhrelid and i.inhparent = c2.oid and c1.relkind = 'r';IF (v_parent IS NOT NULL) THENbPartition   := True;IF bRelispartition THENbInheritance := False;ELSEbInheritance := True;END IF;END IF;END IF;IF bPartition THENIF bInheritance THEN-- inheritance-basedv_table_ddl := 'CREATE TABLE ' || in_schema || '.' || in_table || '( '|| E'\n';-- Jump to constraints section to add the check constraintsELSE-- declarative-basedIF v_relopts <> '' THENv_table_ddl := 'CREATE TABLE ' || in_schema || '.' || in_table || ' PARTITION OF ' || in_schema || '.' || v_parent || ' ' || v_partbound || v_relopts || ' ' || v_tablespace || '; ' || E'\n';ELSEv_table_ddl := 'CREATE TABLE ' || in_schema || '.' || in_table || ' PARTITION OF ' || in_schema || '.' || v_parent || ' ' || v_partbound || ' ' || v_tablespace || '; ' || E'\n';END IF;-- Jump to constraints and index section to add the check constraints and indexes and perhaps FKeysEND IF;END IF;-- RAISE INFO 'DEBUG1: tabledef so far: %', v_table_ddl;IF NOT bPartition THEN-- see if this is unlogged or temporary tableselect c.relpersistence into v_persist from pg_class c, pg_namespace n where n.nspname = in_schema and n.oid = c.relnamespace and c.relname = in_table and c.relkind = 'r';IF v_persist = 'u' THENv_temp := 'UNLOGGED';ELSIF v_persist = 't' THENv_temp := 'TEMPORARY';ELSEv_temp := '';END IF;END IF;-- start the create definition for regular tables unless we are in progress creating an inheritance-based child tableIF NOT bPartition THENv_table_ddl := 'CREATE ' || v_temp || ' TABLE ' || in_schema || '.' || in_table || ' (' || E'\n';END IF;-- RAISE INFO 'DEBUG2: tabledef so far: %', v_table_ddl;    -- define all of the columns in the table unless we are in progress creating an inheritance-based child tableIF NOT bPartition THENFOR v_colrec INSELECT c.column_name, c.data_type, c.udt_name, c.character_maximum_length, c.is_nullable, c.column_default, c.numeric_precision, c.numeric_scale, c.is_identity, c.identity_generation        FROM information_schema.columns c WHERE (table_schema, table_name) = (in_schema, in_table) ORDER BY ordinal_positionLOOPv_table_ddl := v_table_ddl || '  ' -- note: two char spacer to start, to indent the column|| v_colrec.column_name || ' '-- || CASE WHEN v_colrec.data_type = 'USER-DEFINED' THEN in_schema || '.' || v_colrec.udt_name ELSE v_colrec.data_type END || CASE WHEN v_colrec.udt_name in ('geometry', 'box2d', 'box2df', 'box3d', 'geography', 'geometry_dump', 'gidx', 'spheroid', 'valid_detail')THEN v_colrec.udt_name WHEN v_colrec.data_type = 'USER-DEFINED' THEN in_schema || '.' || v_colrec.udt_name ELSE v_colrec.data_type END || CASE WHEN v_colrec.is_identity = 'YES' THEN CASE WHEN v_colrec.identity_generation = 'ALWAYS' THEN ' GENERATED ALWAYS AS IDENTITY' ELSE ' GENERATED BY DEFAULT AS IDENTITY' END ELSE '' END|| CASE WHEN v_colrec.character_maximum_length IS NOT NULL THEN ('(' || v_colrec.character_maximum_length || ')') WHEN v_colrec.numeric_precision > 0 AND v_colrec.numeric_scale > 0 THEN '(' || v_colrec.numeric_precision || ',' || v_colrec.numeric_scale || ')' ELSE '' END || ' '|| CASE WHEN v_colrec.is_nullable = 'NO' THEN 'NOT NULL' ELSE 'NULL' END|| CASE WHEN v_colrec.column_default IS NOT null THEN (' DEFAULT ' || v_colrec.column_default) ELSE '' END|| ',' || E'\n';END LOOP;END IF;-- RAISE INFO 'DEBUG3: tabledef so far: %', v_table_ddl;    -- define all the constraintsFOR v_constraintrec INSELECT con.conname as constraint_name, con.contype as constraint_type,CASEWHEN con.contype = 'p' THEN 1 -- primary key constraintWHEN con.contype = 'u' THEN 2 -- unique constraintWHEN con.contype = 'f' THEN 3 -- foreign key constraintWHEN con.contype = 'c' THEN 4ELSE 5END as type_rank,pg_get_constraintdef(con.oid) as constraint_definitionFROM pg_catalog.pg_constraint con JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid JOIN pg_catalog.pg_namespace nsp ON nsp.oid = connamespaceWHERE nsp.nspname = in_schema AND rel.relname = in_table ORDER BY type_rankLOOPIF v_constraintrec.type_rank = 1 THENv_primary := True;v_constraint_name := v_constraintrec.constraint_name;IF bPartition THENcontinue;END IF;END IF;-- RAISE INFO 'DEBUG4: constraint name= %', v_constraintrec.constraint_name;    constraintarr := constraintarr || string_to_array(v_constraintrec.constraint_name,',');IF in_fktype <> 'FKEYS_INTERNAL' AND v_constraintrec.constraint_type = 'f' THENcontinue;END IF;v_table_ddl := v_table_ddl || '  ' -- note: two char spacer to start, to indent the column|| 'CONSTRAINT' || ' '|| v_constraintrec.constraint_name || ' '|| v_constraintrec.constraint_definition|| ',' || E'\n';END LOOP;-- RAISE INFO 'DEBUG5: tabledef so far: %', v_table_ddl;    -- drop the last comma before ending the create statementv_table_ddl = substr(v_table_ddl, 0, length(v_table_ddl) - 1) || E'\n';-- ----------------------------------------------------------------------------- at this point we have everything up to the last table-enclosing parenthesis-- ----------------------------------------------------------------------------- RAISE NOTICE 'ddlsofar1: %', v_table_ddl;-- See if this is an inheritance-based child table and finish up the table create.IF bPartition and bInheritance THENv_table_ddl := v_table_ddl || ') INHERITS (' || in_schema || '.' || v_parent || ') ' || E'\n' || v_relopts || ' ' || v_tablespace || ';' || E'\n';END IF;IF v_pgversion >= 100000 AND NOT bPartition and NOT bInheritance THEN-- See if this is a partitioned table (pg_class.relkind = 'p') and add the partitioned key SELECT pg_get_partkeydef(c1.oid) as partition_key INTO v_partition_key FROM pg_class c1 JOIN pg_namespace n ON (n.oid = c1.relnamespace) LEFT JOIN pg_partitioned_table p ON (c1.oid = p.partrelid) WHERE n.nspname = in_schema and n.oid = c1.relnamespace and c1.relname = in_table and c1.relkind = 'p';IF v_partition_key IS NOT NULL AND v_partition_key <> '' THEN-- add partition clause-- NOTE:  cannot specify default tablespace for partitioned relations-- v_table_ddl := v_table_ddl || ') PARTITION BY ' || v_partition_key || ' ' || v_tablespace || ';' || E'\n';  v_table_ddl := v_table_ddl || ') PARTITION BY ' || v_partition_key || ';' || E'\n';  ELSEIF v_relopts <> '' THENv_table_ddl := v_table_ddl || ') ' || v_relopts || ' ' || v_tablespace || ';' || E'\n';  ELSE-- end the create definitionv_table_ddl := v_table_ddl || ') ' || v_tablespace || ';' || E'\n';    END IF;  END IF;-- RAISE NOTICE 'ddlsofar2: %', v_table_ddl;-- Add closing paren for regular tables-- IF NOT bPartition THEN-- v_table_ddl := v_table_ddl || ') ' || v_relopts || ' ' || v_tablespace || E';\n';  -- END IF;-- RAISE NOTICE 'ddlsofar3: %', v_table_ddl;-- create indexesFOR v_indexrec INSELECT indexdef, COALESCE(tablespace, 'pg_default') as tablespace, indexname FROM pg_indexes WHERE (schemaname, tablename) = (in_schema, in_table)LOOP-- RAISE INFO 'DEBUG6: indexname=%', v_indexrec.indexname;             -- loop through constraints and skip ones already definedbSkip = False;FOREACH constraintelement IN ARRAY constraintarrLOOP IF constraintelement = v_indexrec.indexname THEN-- RAISE INFO 'DEBUG7: skipping index, %', v_indexrec.indexname;bSkip = True;EXIT;END IF;END LOOP;   if bSkip THEN CONTINUE; END IF;-- Add IF NOT EXISTS clause so partition index additions will not be created if declarative partition in effect and index already created on parentv_indexrec.indexdef := REPLACE(v_indexrec.indexdef, 'CREATE INDEX', 'CREATE INDEX IF NOT EXISTS');-- RAISE INFO 'DEBUG8: adding index, %', v_indexrec.indexname;-- NOTE:  cannot specify default tablespace for partitioned relationsIF v_partition_key IS NOT NULL AND v_partition_key <> '' THENv_table_ddl := v_table_ddl || v_indexrec.indexdef || ';' || E'\n';ELSEv_table_ddl := v_table_ddl || v_indexrec.indexdef || ' TABLESPACE ' || v_indexrec.tablespace || ';' || E'\n';END IF;END LOOP;-- RAISE INFO 'DEBUG9: tabledef so far: %', v_table_ddl;    -- Handle external foreign key defs here if applicable. IF in_fktype = 'FKEYS_EXTERNAL' THENSELECT 'ALTER TABLE ONLY ' || n.nspname || '.' || c2.relname || ' ADD CONSTRAINT ' || r.conname || ' ' || pg_catalog.pg_get_constraintdef(r.oid, true) || ';' into v_fkey_defs FROM pg_constraint r, pg_class c1, pg_namespace n, pg_class c2 where r.conrelid = c1.oid and  r.contype = 'f' and n.nspname = in_schema and n.oid = r.connamespace and r.conrelid = c2.oid and c2.relname = in_table;v_table_ddl := v_table_ddl || v_fkey_defs;ELSIF  in_fktype = 'FKEYS_COMMENTED' THEN SELECT '-- ALTER TABLE ONLY ' || n.nspname || '.' || c2.relname || ' ADD CONSTRAINT ' || r.conname || ' ' || pg_catalog.pg_get_constraintdef(r.oid, true) || ';' into v_fkey_defs FROM pg_constraint r, pg_class c1, pg_namespace n, pg_class c2 where r.conrelid = c1.oid and  r.contype = 'f' and n.nspname = in_schema and n.oid = r.connamespace and r.conrelid = c2.oid and c2.relname = in_table;v_table_ddl := v_table_ddl || v_fkey_defs;END IF;-- RAISE NOTICE 'ddlsofar5: %', v_table_ddl;IF in_trigger = 'INCLUDE_TRIGGERS' THENselect pg_get_triggerdef(t.oid, True) || ';' INTO v_trigger FROM pg_trigger t, pg_class c, pg_namespace n WHERE n.nspname = in_schema and n.oid = c.relnamespace and c.relname = in_table and c.relkind = 'r' and t.tgrelid = c.oid and NOT t.tgisinternal;IF v_trigger <> '' THENv_table_ddl := v_table_ddl || v_trigger;END IF;  END IF;-- add empty linev_table_ddl := v_table_ddl || E'\n';RETURN v_table_ddl;END;
$$;

使用方法如下:

test=# \df *get*tabledef函数列表架构模式 |      名称       | 结果数据类型 |                                                                                        参数数据类型                                                                                         | 类型
----------+-----------------+--------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------public   | pg_get_tabledef | text         | in_schema character varying, in_table character varying, in_fktype tabledef_fkeys DEFAULT 'FKEYS_INTERNAL'::tabledef_fkeys, in_trigger tabledef_trigs DEFAULT 'NO_TRIGGERS'::tabledef_trigs | 函数
(1 行记录)test=# select pg_get_tabledef('test','beijing');pg_get_tabledef
---------------------------------------------------------------------------------------------------------------------------CREATE  TABLE test.beijing (                                                                                              +objectid integer NOT NULL,                                                                                             +name character varying(60) NULL,                                                                                       +idum1 smallint NULL,                                                                                                   +area numeric(38,8) NULL,                                                                                               +gdb_geomattr_data bytea NULL,                                                                                          +shape geometry NULL,                                                                                                   +zz integer NULL,                                                                                                       +CONSTRAINT enforce_srid_shape CHECK ((st_srid(shape) = 3857))                                                          +) TABLESPACE pg_default;                                                                                                 +CREATE UNIQUE INDEX r105_sde_rowid_uk ON test.beijing USING btree (objectid) WITH (fillfactor='75') TABLESPACE pg_default;+CREATE UNIQUE INDEX sde_rix_26 ON test.beijing USING btree (zz) WITH (fillfactor='75') TABLESPACE pg_default;             +CREATE INDEX IF NOT EXISTS a48_ix1 ON test.beijing USING gist (shape) TABLESPACE pg_default;                              ++

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_1026494.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

stm32平衡车

目录 一.所需材料 二.PID算法&#xff08;简单说明&#xff09; 直立环 速度环 串级PID 三.使用到的外设 1.定时器输出比较-PWM 2.定时器编码器模式 3.编码器读取速度 4.电机驱动函数 5.外部中断 四、小车 调试 一.所需材料 1.陀螺仪MPU6050--读取三轴的加速度…

C++:梦的开始——创建第一个hello world(1)

我这里使用的编写代码的工具是Start Experimental Instance of Visual Studio 2022 你可以去微软的官网上寻找&#xff0c;并且安装 部署项目 项目就是一个文件夹&#xff0c;他将我们的数据都放到了里面&#xff0c;这就是一个项目 在Visual Studio 2022中 选择c 的空项目&a…

【Linux 08】进程概念

文章目录 &#x1f308; 01. 基本概念&#x1f308; 02. 描述进程 PCB&#x1f308; 03. 使用 ./ 的方式创建进程&#x1f308; 04. ps 查看进程&#x1f308; 05. getpid / getppid 获取进程标识符&#x1f308; 06. kill 终止指定进程&#x1f308; 07. fork 创建子进程&…

python学习14:python中的表达式

python中的表达式 1.表达式是什么呢&#xff1f; 表达式就是一个具有明确结果的代码语句&#xff0c;如11、type(‘字符串’)、3*5等 在定义变量的时候&#xff0c;如age108,等号右侧的就是表达式&#xff0c;也就是有具体的结果&#xff0c;将结果赋值给了等号左侧的变量 2.…

Linux 系统基础操作命令

当前市面上常见的系统&#xff1a;Windows、Linux、Mac OS、Android、IOS…… Linux 不太适合日常使用&#xff0c;但是非常适合用于开发。因此作为一个程序猿来说&#xff0c;Linux 都是务必要掌握的。 Linux 介绍 Linux 发行版 目前市面上比较知名的发行版有&#xff1a;R…

DNS隧道攻击

什么是DNS隧道&#xff1f; DNS隧道是一种网络通信技术&#xff0c;它利用DNS&#xff08;Domain Name System&#xff0c;域名系统&#xff09;协议来建立隐蔽的通信通道。在正常情况下&#xff0c;DNS协议主要用于将域名解析为IP地址&#xff0c;但攻击者可以通过构造特殊的…

总结 | vue3项目初始化(附相应链接)

如何运行 vue 项目&#xff1a;vscode运行vue项目_vscode启动vue项目命令-CSDN博客 vue3项目搭建 目录管理 git管理&#xff1a;vue3项目搭建并git管理_git 新建vue3项目-CSDN博客 目录调整&#xff1a;vue3项目 - 目录调整-CSDN博客 vscode中快速生成vue3模板&#xff1a…

实现能效升级 | 基于ACM32 MCU的冰箱压缩机变频方案

概述 冰箱制冷系统中最重要的部件是压缩机。它从吸气管吸入低温低压的制冷剂气体&#xff0c;通过电机运转带动活塞对其进行压缩后&#xff0c;向排气管排出高温高压的制冷剂气体&#xff0c;为整个制冷循环提供源动力。这样就实现了压缩→冷凝→膨胀→蒸发 ( 吸热 ) 的制冷循环…

并查集|1971. 寻找图中是否存在路径、684.冗余连接、685.冗余连接II

目录 并查集基础 1971. 寻找图中是否存在路径 684.冗余连接 685.冗余连接II 并查集基础 并查集主要有三个功能。 寻找根节点&#xff0c;函数&#xff1a;find(int u)&#xff0c;也就是判断这个节点的祖先节点是哪个将两个节点接入到同一个集合&#xff0c;函数&#xf…

项目中自动引入神器 - unplugin-auto-import/unplugin-vue-components

前端 项目中 自动引入 神器 前言 在开发中&#xff0c;我们总喜欢站在巨人的肩膀上开发&#xff0c;比如用一些 框架&#xff1a;vue,react, 组件库&#xff1a;element&#xff0c;ant。 工具函数&#xff1a;axios&#xff0c;lodash 现在是模块化时代&#xff0c;我们…

新手入门C语言之联合体和枚举

在上一篇文章中&#xff0c;我们了解到在C语言中&#xff0c;自定义类型有三种&#xff0c;这里我们介绍后两种&#xff0c;联合体和枚举。 一.联合体 1.联合体的声明 像结构体一样&#xff0c;联合体也是由一个或多个成员构成&#xff0c;这些成员的类型可以是不一样的&…

Go——结构体

Go语言中没有类的概念&#xff0c;也不支持类的继承等面向对象的概念。Go语言中通过结构体的内嵌再配合接口比面向对象具有更高的扩展性和灵活性。 一. 类型别名和自定义类型 1.1 自定义类型 在Go语言中有一些基本的数据类型&#xff0c;如string&#xff0c;整型&#xff0c;…

手机网页关键词视频爬虫采集软件可导出视频分享链接|视频无水印批量下载工具

全新音视频批量下载工具&#xff0c;为您解放视频管理烦恼&#xff01; 现如今&#xff0c;音上涌现出大量精彩的视频内容&#xff0c;但是要想高效地获取、管理和分享这些视频却是一件颇具挑战的事情。针对这一难题&#xff0c;我们自主研发了全新的音视频批量下载工具&#x…

数学建模体育建模和经济建模国防科大版

目录 6.体育中的数学建模 7.经济学问题中的数学建模 7.1.实物交换模型 7.2.边际效应 7.3.最佳消费选择模型 6.体育中的数学建模 体育科学的研究中&#xff0c;也有大量的数学建模问题&#xff0c;例如&#xff1a;棒球的最佳击球点问题、滑板滑雪赛道的设计、越野自行车比…

各种需要使用的方法-->vue/微信小程序/layui

各种需要使用的方法-->vue/微信小程序/layui 1、vue里样式不起作用的方法&#xff0c;可以通过deep穿透的方式2、 js获取本周、上周、本月、上月日期3、ArrayBuffer Blob 格式转换ArrayBuffer与Blob的区别ArrayBuffer转BlobBlob转ArrayBuffer需要借助fileReader对象 4、使用…

STM32使用滴答定时器实现delayms

在STM32上使用SysTick实现jiffies&#xff08;时间戳&#xff09;并且实现delay_ms 代码实现&#xff1a; volatile uint32_t jiffies 0; // 用于记录系统运行的jiffies数 void SysTick_Handler(void) {/* 每次SysTick中断&#xff0c;jiffies增加 */jiffies; }uint32_t tick…

如何利用生成式人工智能挑选合适的候选人?

在当今激烈的商业竞争中&#xff0c;招聘合适的人才是构建企业成功的基石。筛选和面试候选人是一个复杂且精细的过程&#xff0c;它不仅关系到职位的有效填补&#xff0c;更影响到企业的长期发展和团队建设。 选择合适候选人的重要性 选择合适的候选人就像寻找一片沙滩上的珍…

曲线生成 | 图解Reeds-Shepp曲线生成原理(附ROS C++/Python/Matlab仿真)

目录 0 专栏介绍1 什么是Reeds-Shepp曲线&#xff1f;2 Reeds-Shepp曲线的运动模式3 Reeds-Shepp曲线算法原理3.1 坐标变换3.2 时间翻转(time-flip)3.3 反射变换(reflect)3.4 后向变换(backwards) 4 仿真实现4.1 ROS C实现4.2 Python实现4.3 Matlab实现 0 专栏介绍 &#x1f5…

MP4如何把视频转MOV格式? MP4视频转MOV格式的技巧

在现代的数字媒体时代&#xff0c;视频格式转换成为了许多用户必须掌握的技能。特别是将MP4视频转换为MOV格式&#xff0c;这对于需要在Apple设备上播放或编辑视频的用户来说尤为重要。本文将详细介绍如何将MP4视频转换为MOV格式&#xff0c;帮助读者轻松应对不同设备和平台的需…

编程语言|C语言——C语言基本数据类型

前言 针对不同的数据&#xff0c;采取不同的存储方式和进行不同的处理。随着处理对象的复杂化&#xff0c;数据类型也要变得更丰富。数据类型的丰富程度直接反映了程序设计语言处理数据的能力。 C语言很重要的一个特点是它的数据类型十分丰富。因此&#xff0c;C语言程序数据处…